1 /-
2 Copyright (c) 2014 Jeremy Avigad. All rights reserved.
3 Released under Apache 2.0 license as described in the file LICENSE.
4 Author: Jeremy Avigad, Leonardo de Moura
5 -/
6 import tactic.basic tactic.finish data.subtype logic.unique
src └──────────┘ └───────────┘ └──────────┘ └──────────┘
7 open function
8
9 /-! # Basic properties of sets
10
11 This file provides some basic definitions related to sets and functions (e.g., `preimage`)
12 not present in the core library, as well as extra lemmas.
13 -/
14
15 /-! ### Set coercion to a type -/
16 namespace set
17 instance {α : Type*} : has_coe_to_sort (set α) := ⟨_, λ s, {x // x ∈ s}⟩
id └─────────────┘ └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴
src └─────────────┘ └─┘ ┴ ┴
typ └─────────────┘ └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴
18 end set
19
20 section set_coe
21 universe u
22 variables {α : Type u}
23 theorem set.set_coe_eq_subtype (s : set α) :
id └─┘ ┴
src └─┘
typ └─┘ ┴
24 coe_sort.{(u+1) (u+2)} s = {x // x ∈ s} := rfl
id └──────┘ ┴ ┴ ┴┴ ┴ ┴ ┴ └─┘
src └──────┘ ┴ ┴ ┴ └─┘
typ └──────┘ ┴ ┴ ┴┴ ┴ ┴ ┴ └─┘
25
26 @[simp] theorem set_coe.forall {s : set α} {p : s → Prop} :
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
doc └──┘
27 (∀ x : s, p x) ↔ (∀ x (h : x ∈ s), p ⟨x, h⟩) :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
28 subtype.forall
id └────────────┘
src └────────────┘
typ └────────────┘
29
30 @[simp] theorem set_coe.exists {s : set α} {p : s → Prop} :
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
doc └──┘
31 (∃ x : s, p x) ↔ (∃ x (h : x ∈ s), p ⟨x, h⟩) :=
id ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
32 subtype.exists
id └────────────┘
src └────────────┘
typ └────────────┘
33
34 @[simp] theorem set_coe_cast : ∀ {s t : set α} (H' : s = t) (H : @eq (Type u) s t) (x : s),
id ┴ └─┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src └─┘ ┴ └┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
doc └──┘
35 cast H x = ⟨x.1, H' ▸ x.2⟩
id └──┘ ┴ ┴ ┴ ┴┴ └┘ ┴ ┴┴
src └──┘ ┴ ┴ ┴ ┴
typ └──┘ ┴ ┴ ┴ ┴┴ └┘ ┴ ┴┴
36 | s _ rfl _ ⟨x, h⟩ := rfl
id └─┘ └─┘
src └─┘ └─┘
typ └─┘ └─┘
37
38 theorem set_coe.ext {s : set α} {a b : s} : (↑a : α) = ↑b → a = b :=
id └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ ┴
39 subtype.eq
id └────────┘
src └────────┘
typ └────────┘
40
41 theorem set_coe.ext_iff {s : set α} {a b : s} : (↑a : α) = ↑b ↔ a = b :=
id └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴
42 iff.intro set_coe.ext (assume h, h ▸ rfl)
id └───────┘ └─────────┘ ┴ ┴ ┴ └─┘
src └───────┘ └─────────┘ ┴ └─┘
typ └───────┘ └─────────┘ ┴ ┴ ┴ └─┘
43
44 end set_coe
45
46 lemma subtype.mem {α : Type*} {s : set α} (p : s) : (p : α) ∈ s := p.property
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
src └─┘ ┴ └───────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
47
48 namespace set
49 universes u v w x
50 variables {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a : α} {s t : set α}
id └─┘
src └─┘
typ └─┘
51
52 instance : inhabited (set α) := ⟨∅⟩
id └───────┘ └─┘ ┴ ┴
src └───────┘ └─┘ ┴
typ └───────┘ └─┘ ┴ ┴
53
54 @[ext]
doc └─┘
55 theorem ext {a b : set α} (h : ∀ x, x ∈ a ↔ x ∈ b) : a = b :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
56 funext (assume x, propext (h x))
id └────┘ ┴ └─────┘ ┴ ┴
src └────┘ └─────┘
typ └────┘ ┴ └─────┘ ┴ ┴
57
58 theorem ext_iff (s t : set α) : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
59 ⟨λ h x, by rw h, ext⟩
id ┴ ┴ ┴ └─┘
src └─┘ └─┘
typ ┴ ┴ └─┘┴ └─┘
doc └─┘
txt └─┘
par └─┘
pid ┴
st └───┘
60
61 @[trans] theorem mem_of_mem_of_subset {α : Type u} {x : α} {s t : set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───┘ └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘
62 h hx
id ┴ └┘
typ ┴ └┘
63
64 /-! ### Lemmas about `mem` and `set_of` -/
65
66 @[simp] theorem mem_set_of_eq {a : α} {p : α → Prop} : a ∈ {a | p a} = p a := rfl
id ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
src ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
67
68 @[simp] theorem nmem_set_of_eq {a : α} {P : α → Prop} : a ∉ {a : α | P a} = ¬ P a := rfl
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
69
70 @[simp] theorem set_of_mem_eq {s : set α} : {x | x ∈ s} = s := rfl
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
71
72 lemma set_of_app_iff {p : α → Prop} {x : α} : { x | p x } x ↔ p x := iff.rfl
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src ┴ ┴ └─────┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
73
74 theorem mem_def {a : α} {s : set α} : a ∈ s ↔ s a := iff.rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ └─────┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
75
76 instance decidable_mem (s : set α) [H : decidable_pred s] : ∀ a, decidable (a ∈ s) := H
id └─┘ ┴ └────────────┘ ┴ ┴ └───────┘ ┴ ┴ ┴ ┴
src └─┘ └────────────┘ └───────┘ ┴
typ └─┘ ┴ └────────────┘ ┴ ┴ └───────┘ ┴ ┴ ┴ ┴
77
78 instance decidable_set_of (p : α → Prop) [H : decidable_pred p] : decidable_pred {a | p a} := H
id ┴ └────────────┘ ┴ └────────────┘ ┴┴ ┴ ┴ ┴
src └────────────┘ └────────────┘ ┴
typ ┴ └────────────┘ ┴ └────────────┘ ┴┴ ┴ ┴ ┴
79
80 @[simp] theorem set_of_subset_set_of {p q : α → Prop} : {a | p a} ⊆ {a | q a} ↔ (∀a, p a → q a) := iff.rfl
id ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src ┴ ┴ ┴ ┴ └─────┘
typ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘
81
82 @[simp] lemma sep_set_of {α} {p q : α → Prop} : {a ∈ {a | p a } | q a} = {a | p a ∧ q a} :=
id ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
83 rfl
id └─┘
src └─┘
typ └─┘
84
85 @[simp] lemma set_of_mem {α} {s : set α} : {a | a ∈ s} = s := rfl
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
86
87 /-! #### Lemmas about subsets -/
88
89 -- TODO(Jeremy): write a tactic to unfold specific instances of generic notation?
90 theorem subset_def {s t : set α} : (s ⊆ t) = ∀ x, x ∈ s → x ∈ t := rfl
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
91
92 @[refl] theorem subset.refl (a : set α) : a ⊆ a := assume x, id
id └─┘ ┴ ┴ ┴ ┴ ┴ └┘
src └──┘ └─┘ ┴ └┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ └┘
doc └──┘
93
94 @[trans] theorem subset.trans {a b c : set α} (ab : a ⊆ b) (bc : b ⊆ c) : a ⊆ c :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───┘ └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘
95 assume x h, bc (ab h)
id ┴ ┴ └┘ └┘ ┴
typ ┴ ┴ └┘ └┘ ┴
96
97 @[trans] theorem mem_of_eq_of_mem {α : Type u} {x y : α} {s : set α} (hx : x = y) (h : y ∈ s) : x ∈ s :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───┘ └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘
98 hx.symm ▸ h
id └┘└───┘ ┴ ┴
src └───┘ ┴
typ └┘└───┘ ┴ ┴
99
100 theorem subset.antisymm {a b : set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
101 ext (λ x, iff.intro (λ ina, h₁ ina) (λ inb, h₂ inb))
id └─┘ ┴ └───────┘ └─┘ └┘ └─┘ └─┘ └┘ └─┘
src └─┘ └───────┘
typ └─┘ ┴ └───────┘ └─┘ └┘ └─┘ └─┘ └┘ └─┘
102
103 theorem subset.antisymm_iff {a b : set α} : a = b ↔ a ⊆ b ∧ b ⊆ a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
104 ⟨λ e, e ▸ ⟨subset.refl _, subset.refl _⟩,
id ┴ ┴ ┴ └─────────┘ └─────────┘
src ┴ └─────────┘ └─────────┘
typ ┴ ┴ ┴ └─────────┘ └─────────┘
105 λ ⟨h₁, h₂⟩, subset.antisymm h₁ h₂⟩
id ┴└┘ └┘ └─────────────┘
src └─────────────┘
typ ┴└┘ └┘ └─────────────┘
106
107 -- an alterantive name
108 theorem eq_of_subset_of_subset {a b : set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
109 subset.antisymm h₁ h₂
id └─────────────┘ └┘ └┘
src └─────────────┘
typ └─────────────┘ └┘ └┘
110
111 theorem mem_of_subset_of_mem {s₁ s₂ : set α} {a : α} : s₁ ⊆ s₂ → a ∈ s₁ → a ∈ s₂ :=
id └─┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ ┴ └┘
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ ┴ └┘
112 assume h₁ h₂, h₁ h₂
id └┘ └┘ └┘ └┘
typ └┘ └┘ └┘ └┘
113
114 theorem not_subset : (¬ s ⊆ t) ↔ ∃a ∈ s, a ∉ t :=
id ┴ ┴ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴ ┴
115 by simp [subset_def, classical.not_forall]
id └────────┘ └──────────────────┘
src └────┘└────────┘└┘└──────────────────┘└─
typ └────┘└────────┘└┘└──────────────────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └────────────────────────────────────────
116
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
117 /-! ### Definition of strict subsets `s ⊂ t` and basic properties. -/
118
119 /-- `s ⊂ t` means that `s` is a strict subset of `t`, that is, `s ⊆ t` but `s ≠ t`. -/
120 def strict_subset (s t : set α) := s ⊆ t ∧ ¬ (t ⊆ s)
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
121
122 instance : has_ssubset (set α) := ⟨strict_subset⟩
id └─────────┘ └─┘ ┴ └───────────┘
src └─────────┘ └─┘ └───────────┘
typ └─────────┘ └─┘ ┴ └───────────┘
doc └───────────┘
123
124 theorem ssubset_def : (s ⊂ t) = (s ⊆ t ∧ ¬ (t ⊆ s)) := rfl
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
125
126 theorem eq_or_ssubset_of_subset (h : s ⊆ t) : s = t ∨ s ⊂ t :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
127 classical.by_cases
id └────────────────┘
src └────────────────┘
typ └────────────────┘
128 (λ H : t ⊆ s, or.inl $ subset.antisymm h H)
id ┴ ┴ ┴ └────┘ └─────────────┘ ┴ ┴
src ┴ └────┘ └─────────────┘
typ ┴ ┴ ┴ └────┘ └─────────────┘ ┴ ┴
129 (λ H, or.inr ⟨h, H⟩)
id ┴ └────┘ ┴ ┴
src └────┘
typ ┴ └────┘ ┴ ┴
130
131 lemma exists_of_ssubset {α : Type u} {s t : set α} (h : s ⊂ t) : (∃x∈t, x ∉ s) :=
id └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴ ┴
132 not_subset.1 h.2
id └────────┘┴ ┴┴
src └────────┘┴ ┴
typ └────────┘┴ ┴┴
133
134 lemma ssubset_iff_subset_ne {s t : set α} : s ⊂ t ↔ s ⊆ t ∧ s ≠ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
135 by split; simp [set.ssubset_def, ne.def, set.subset.antisymm_iff] {contextual := tt}
id └─────────────┘ └────┘ └─────────────────────┘ └┘
src └───┘ └────┘└─────────────┘└┘└────┘└┘└─────────────────────┘└┘ └────────────┘└┘└─
typ └───┘ └────┘└─────────────┘└┘└────┘└┘└─────────────────────┘└┘ └────────────┘└┘└─
doc └───┘ └────┘ └┘ └┘ └┘ └────────────┘ └─
txt └───┘ └────┘ └┘ └┘ └┘ └────────────┘ └─
par └───┘ └────┘ └┘ └┘ └┘ └────────────┘ └─
pid ┴┴ └┘ └┘ ┴┴ └────────────┘ ┴└
st └──────────────────────────────────────────────────────────────────────────────────
136
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
137 theorem not_mem_empty (x : α) : ¬ (x ∈ (∅ : set α)) :=
id ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
138 assume h : x ∈ ∅, h
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
139
140 @[simp] theorem not_not_mem [decidable (a ∈ s)] : ¬ (a ∉ s) ↔ a ∈ s :=
id └───────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───────┘ ┴ ┴ ┴ ┴ ┴
typ └───────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
141 not_not
id └─────┘
src └─────┘
typ └─────┘
142
143 /-! ### Non-empty sets -/
144
145 /-- The property `s.nonempty` expresses the fact that the set `s` is not empty. It should be used
146 in theorem assumptions instead of `∃ x, x ∈ s` or `s ≠ ∅` as it gives access to a nice API thanks
147 to the dot notation. -/
148 protected def nonempty (s : set α) : Prop := ∃ x, x ∈ s
id └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴┴ ┴ ┴ ┴
149
150 lemma nonempty_of_mem {x} (h : x ∈ s) : s.nonempty := ⟨x, h⟩
id ┴ ┴ ┴ ┴└───────┘ ┴ ┴
src ┴ └───────┘
typ ┴ ┴ ┴ ┴└───────┘ ┴ ┴
doc └───────┘
151
152 theorem nonempty.ne_empty : s.nonempty → s ≠ ∅
id ┴└───────┘ ┴ ┴ ┴ ┴
src └───────┘ ┴ ┴
typ ┴└───────┘ ┴ ┴ ┴ ┴
doc └───────┘
153 | ⟨x, hx⟩ hs := by { rw hs at hx, exact hx }
id └┘ └┘
src └─┘ └────┘ └────┘ ┴
typ └─┘└┘└────┘ └────┘└┘┴
doc └─┘ └────┘ └────┘ ┴
txt └─┘ └────┘ └────┘ ┴
par └─┘ └────┘ └────┘ ┴
pid ┴ └────┘ ┴ ┴
st └────────────┘└─────────┘└┘
154
155 /-- Extract a witness from `s.nonempty`. This function might be used instead of case analysis
156 on the argument. Note that it makes a proof depend on the `classical.choice` axiom. -/
157 protected noncomputable def nonempty.some (h : s.nonempty) : α := classical.some h
id ┴└───────┘ ┴ └────────────┘ ┴
src └───────┘ └────────────┘
typ ┴└───────┘ ┴ └────────────┘ ┴
doc └───────┘
158
159 protected lemma nonempty.some_mem (h : s.nonempty) : h.some ∈ s := classical.some_spec h
id ┴└───────┘ ┴└───┘ ┴ ┴ └─────────────────┘ ┴
src └───────┘ └───┘ ┴ └─────────────────┘
typ ┴└───────┘ ┴└───┘ ┴ ┴ └─────────────────┘ ┴
doc └───────┘ └───┘
160
161 lemma nonempty.mono (ht : s ⊆ t) (hs : s.nonempty) : t.nonempty := hs.imp ht
id ┴ ┴ ┴ ┴└───────┘ ┴└───────┘ └┘└──┘ └┘
src ┴ └───────┘ └───────┘ └──┘
typ ┴ ┴ ┴ ┴└───────┘ ┴└───────┘ └┘└──┘ └┘
doc └───────┘ └───────┘
162
163 lemma nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).nonempty :=
id ┴ ┴ ┴ ┴ ┴ ┴ └──────┘
src ┴ ┴ └──────┘
typ ┴ ┴ ┴ ┴ ┴ ┴ └──────┘
doc └──────┘
164 let ⟨x, xt, xs⟩ := exists_of_ssubset ht in ⟨x, xt, xs⟩
id └─┘ ┴ └┘ └┘ └───────────────┘ └┘
src └───────────────┘
typ └─┘ ┴ └┘ └┘ └───────────────┘ └┘
165
166 lemma nonempty.of_diff (h : (s \ t).nonempty) : s.nonempty := h.imp $ λ _, and.left
id ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └──────┘
src ┴ └──────┘ └───────┘ └──┘ └──────┘
typ ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └──────┘
doc └──────┘ └───────┘
167
168 lemma nonempty_of_ssubset' (ht : s ⊂ t) : t.nonempty := (nonempty_of_ssubset ht).of_diff
id ┴ ┴ ┴ ┴└───────┘ └─────────────────┘ └┘ └─────┘
src ┴ └───────┘ └─────────────────┘ └─────┘
typ ┴ ┴ ┴ ┴└───────┘ └─────────────────┘ └┘ └─────┘
doc └───────┘
169
170 lemma nonempty.inl (hs : s.nonempty) : (s ∪ t).nonempty := hs.imp $ λ _, or.inl
id ┴└───────┘ ┴ ┴ ┴ └──────┘ └┘└──┘ ┴ └────┘
src └───────┘ ┴ └──────┘ └──┘ └────┘
typ ┴└───────┘ ┴ ┴ ┴ └──────┘ └┘└──┘ ┴ └────┘
doc └───────┘ └──────┘
171
172 lemma nonempty.inr (ht : t.nonempty) : (s ∪ t).nonempty := ht.imp $ λ _, or.inr
id ┴└───────┘ ┴ ┴ ┴ └──────┘ └┘└──┘ ┴ └────┘
src └───────┘ ┴ └──────┘ └──┘ └────┘
typ ┴└───────┘ ┴ ┴ ┴ └──────┘ └┘└──┘ ┴ └────┘
doc └───────┘ └──────┘
173
174 @[simp] lemma union_nonempty : (s ∪ t).nonempty ↔ s.nonempty ∨ t.nonempty := exists_or_distrib
id ┴ ┴ ┴ └──────┘ ┴ ┴└───────┘ ┴ ┴└───────┘ └───────────────┘
src ┴ └──────┘ ┴ └───────┘ ┴ └───────┘ └───────────────┘
typ ┴ ┴ ┴ └──────┘ ┴ ┴└───────┘ ┴ ┴└───────┘ └───────────────┘
doc └──┘ └──────┘ └───────┘ └───────┘
175
176 lemma nonempty.left (h : (s ∩ t).nonempty) : s.nonempty := h.imp $ λ _, and.left
id ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └──────┘
src ┴ └──────┘ └───────┘ └──┘ └──────┘
typ ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └──────┘
doc └──────┘ └───────┘
177
178 lemma nonempty.right (h : (s ∩ t).nonempty) : t.nonempty := h.imp $ λ _, and.right
id ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └───────┘
src ┴ └──────┘ └───────┘ └──┘ └───────┘
typ ┴ ┴ ┴ └──────┘ ┴└───────┘ ┴└──┘ ┴ └───────┘
doc └──────┘ └───────┘
179
180 lemma nonempty_iff_univ_nonempty : nonempty α ↔ (univ : set α).nonempty :=
id └──────┘ ┴ ┴ └──┘ └─┘ ┴ └──────┘
src └──────┘ ┴ └──┘ └─┘ └──────┘
typ └──────┘ ┴ ┴ └──┘ └─┘ ┴ └──────┘
doc └──────┘
181 ⟨λ ⟨x⟩, ⟨x, trivial⟩, λ ⟨x, _⟩, ⟨x⟩⟩
id ┴┴ └─────┘ ┴┴
src └─────┘
typ ┴┴ └─────┘ ┴┴
182
183 @[simp] lemma univ_nonempty : ∀ [h : nonempty α], (univ : set α).nonempty
id ┴ └──────┘ ┴ └──┘ └─┘ ┴ └──────┘
src └──────┘ └──┘ └─┘ └──────┘
typ ┴ └──────┘ ┴ └──┘ └─┘ ┴ └──────┘
doc └──┘ └──────┘
184 | ⟨x⟩ := ⟨x, trivial⟩
id ┴ └─────┘
src └─────┘
typ ┴ └─────┘
185
186 lemma nonempty.to_subtype (h : s.nonempty) : nonempty s :=
id ┴└───────┘ └──────┘ ┴
src └───────┘ └──────┘
typ ┴└───────┘ └──────┘ ┴
doc └───────┘
187 nonempty_subtype.2 h
id └──────────────┘┴ ┴
src └──────────────┘┴
typ └──────────────┘┴ ┴
188
189 /-! ### Lemmas about the empty set -/
190
191 theorem empty_def : (∅ : set α) = {x | false} := rfl
id ┴ └─┘ ┴ ┴ ┴┴ └───┘ └─┘
src ┴ └─┘ ┴ ┴ └───┘ └─┘
typ ┴ └─┘ ┴ ┴ ┴┴ └───┘ └─┘
192
193 @[simp] theorem mem_empty_eq (x : α) : x ∈ (∅ : set α) = false := rfl
id ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └───┘ └─┘
src ┴ ┴ └─┘ ┴ └───┘ └─┘
typ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └───┘ └─┘
doc └──┘
194
195 @[simp] theorem set_of_false : {a : α | false} = ∅ := rfl
id ┴ ┴ └───┘ ┴ ┴ └─┘
src ┴ └───┘ ┴ ┴ └─┘
typ ┴ ┴ └───┘ ┴ ┴ └─┘
doc └──┘
196
197 theorem eq_empty_iff_forall_not_mem {s : set α} : s = ∅ ↔ ∀ x, x ∉ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
198 by simp [ext_iff]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
199
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
200 @[simp] theorem empty_subset (s : set α) : ∅ ⊆ s :=
id └─┘ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴
doc └──┘
201 assume x, assume h, false.elim h
id ┴ ┴ └────────┘ ┴
src └────────┘
typ ┴ ┴ └────────┘ ┴
202
203 theorem subset_empty_iff {s : set α} : s ⊆ ∅ ↔ s = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
204 by simp [subset.antisymm_iff]
id └─────────────────┘
src └────┘└─────────────────┘└─
typ └────┘└─────────────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────────────────
205
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
206 theorem eq_empty_of_subset_empty {s : set α} : s ⊆ ∅ → s = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
207 subset_empty_iff.1
id └──────────────┘┴
src └──────────────┘┴
typ └──────────────┘┴
208
209 lemma not_nonempty_iff_eq_empty {s : set α} : ¬s.nonempty ↔ s = ∅ :=
id └─┘ ┴ ┴┴└───────┘ ┴ ┴ ┴ ┴
src └─┘ ┴ └───────┘ ┴ ┴ ┴
typ └─┘ ┴ ┴┴└───────┘ ┴ ┴ ┴ ┴
doc └───────┘
210 by simp only [set.nonempty, eq_empty_iff_forall_not_mem, not_exists]
id └──────────┘ └─────────────────────────┘ └────────┘
src └─────────┘└──────────┘└┘└─────────────────────────┘└┘└────────┘└─
typ └─────────┘└──────────┘└┘└─────────────────────────┘└┘└────────┘└─
doc └─────────┘└──────────┘└┘ └┘ └─
txt └─────────┘ └┘ └┘ └─
par └─────────┘ └┘ └┘ └─
pid ┴└──┘└┘ └┘ └┘ ┴└
st └──────────────────────────────────────────────────────────────────
211
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
212 lemma empty_not_nonempty : ¬(∅ : set α).nonempty :=
id ┴ ┴ └─┘ ┴ └──────┘
src ┴ ┴ └─┘ └──────┘
typ ┴ ┴ └─┘ ┴ └──────┘
doc └──────┘
213 not_nonempty_iff_eq_empty.2 rfl
id └───────────────────────┘┴ └─┘
src └───────────────────────┘┴ └─┘
typ └───────────────────────┘┴ └─┘
214
215 lemma eq_empty_or_nonempty (s : set α) : s = ∅ ∨ s.nonempty :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
src └─┘ ┴ ┴ ┴ └───────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
doc └───────┘
216 classical.by_cases or.inr (λ h, or.inl $ not_nonempty_iff_eq_empty.1 h)
id └────────────────┘ └────┘ ┴ └────┘ └───────────────────────┘┴ ┴
src └────────────────┘ └────┘ └────┘ └───────────────────────┘┴
typ └────────────────┘ └────┘ ┴ └────┘ └───────────────────────┘┴ ┴
217
218 @[simp] theorem ne_empty_iff_nonempty : s ≠ ∅ ↔ s.nonempty :=
id ┴ ┴ ┴ ┴ ┴└───────┘
src ┴ ┴ ┴ └───────┘
typ ┴ ┴ ┴ ┴ ┴└───────┘
doc └──┘ └───────┘
219 (not_congr not_nonempty_iff_eq_empty.symm).trans classical.not_not
id └───────┘ └───────────────────────┘└───┘ └───┘ └───────────────┘
src └───────┘ └───────────────────────┘└───┘ └───┘ └───────────────┘
typ └───────┘ └───────────────────────┘└───┘ └───┘ └───────────────┘
220
221 theorem subset_eq_empty {s t : set α} (h : t ⊆ s) (e : s = ∅) : t = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
222 subset_empty_iff.1 $ e ▸ h
id └──────────────┘┴ ┴ ┴ ┴
src └──────────────┘┴ ┴
typ └──────────────┘┴ ┴ ┴ ┴
223
224 theorem ball_empty_iff {p : α → Prop} :
id ┴
typ ┴
225 (∀ x ∈ (∅ : set α), p x) ↔ true :=
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └──┘
src ┴ ┴ └─┘ ┴ └──┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └──┘
226 by simp [iff_def]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
227
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
228 /-! ### Universal set.
229
230 In Lean `@univ α` (or `univ : set α`) is the set that contains all elements of type `α`.
231 Mathematically it is the same as `α` but it has a different type. -/
232
233 theorem univ_def : @univ α = {x | true} := rfl
id └──┘ ┴ ┴ ┴┴ └──┘ └─┘
src └──┘ ┴ ┴ └──┘ └─┘
typ └──┘ ┴ ┴ ┴┴ └──┘ └─┘
234
235 @[simp] theorem mem_univ (x : α) : x ∈ @univ α := trivial
id ┴ ┴ ┴ └──┘ ┴ └─────┘
src ┴ └──┘ └─────┘
typ ┴ ┴ ┴ └──┘ ┴ └─────┘
doc └──┘
236
237 theorem empty_ne_univ [h : inhabited α] : (∅ : set α) ≠ univ :=
id └───────┘ ┴ ┴ └─┘ ┴ ┴ └──┘
src └───────┘ ┴ └─┘ ┴ └──┘
typ └───────┘ ┴ ┴ └─┘ ┴ ┴ └──┘
238 by simp [ext_iff]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
239
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
240 @[simp] theorem subset_univ (s : set α) : s ⊆ univ := λ x H, trivial
id └─┘ ┴ ┴ ┴ └──┘ ┴ ┴ └─────┘
src └─┘ ┴ └──┘ └─────┘
typ └─┘ ┴ ┴ ┴ └──┘ ┴ ┴ └─────┘
doc └──┘
241
242 theorem univ_subset_iff {s : set α} : univ ⊆ s ↔ s = univ :=
id └─┘ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └──┘
src └─┘ └──┘ ┴ ┴ ┴ └──┘
typ └─┘ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └──┘
243 by simp [subset.antisymm_iff]
id └─────────────────┘
src └────┘└─────────────────┘└─
typ └────┘└─────────────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────────────────
244
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
245 theorem eq_univ_of_univ_subset {s : set α} : univ ⊆ s → s = univ :=
id └─┘ ┴ └──┘ ┴ ┴ ┴ ┴ └──┘
src └─┘ └──┘ ┴ ┴ └──┘
typ └─┘ ┴ └──┘ ┴ ┴ ┴ ┴ └──┘
246 univ_subset_iff.1
id └─────────────┘┴
src └─────────────┘┴
typ └─────────────┘┴
247
248 theorem eq_univ_iff_forall {s : set α} : s = univ ↔ ∀ x, x ∈ s :=
id └─┘ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └──┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴
249 by simp [ext_iff]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
250
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
251 theorem eq_univ_of_forall {s : set α} : (∀ x, x ∈ s) → s = univ := eq_univ_iff_forall.2
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──┘ └────────────────┘┴
src └─┘ ┴ ┴ └──┘ └────────────────┘┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──┘ └────────────────┘┴
252
253 @[simp] lemma univ_eq_empty_iff {α : Type*} : (univ : set α) = ∅ ↔ ¬ nonempty α :=
id └──┘ └─┘ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
src └──┘ └─┘ ┴ ┴ ┴ ┴ └──────┘
typ └──┘ └─┘ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
doc └──┘
254 eq_empty_iff_forall_not_mem.trans ⟨λ H ⟨x⟩, H x trivial, λ H x _, H ⟨x⟩⟩
id └─────────────────────────┘└────┘ ┴ ┴┴ ┴ └─────┘ ┴ ┴ ┴ ┴ ┴
src └─────────────────────────┘└────┘ └─────┘
typ └─────────────────────────┘└────┘ ┴ ┴┴ ┴ └─────┘ ┴ ┴ ┴ ┴ ┴
255
256 lemma exists_mem_of_nonempty (α) : ∀ [nonempty α], ∃x:α, x ∈ (univ : set α)
id ┴└──────┘ ┴ ┴ ┴┴ ┴ ┴ └──┘ └─┘ ┴
src └──────┘ ┴ ┴ ┴ └──┘ └─┘
typ ┴└──────┘ ┴ ┴ ┴┴ ┴ ┴ └──┘ └─┘ ┴
257 | ⟨x⟩ := ⟨x, trivial⟩
id ┴ └─────┘
src └─────┘
typ ┴ └─────┘
258
259 instance univ_decidable : decidable_pred (@set.univ α) :=
id └────────────┘ └──────┘ ┴
src └────────────┘ └──────┘
typ └────────────┘ └──────┘ ┴
260 λ x, is_true trivial
id ┴ └─────┘ └─────┘
src └─────┘ └─────┘
typ ┴ └─────┘ └─────┘
261
262 /-! ### Lemmas about union -/
263
264 theorem union_def {s₁ s₂ : set α} : s₁ ∪ s₂ = {a | a ∈ s₁ ∨ a ∈ s₂} := rfl
id └─┘ ┴ └┘ ┴ └┘ ┴ ┴┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ └─┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ └┘ ┴ └┘ ┴ ┴┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ └─┘
265
266 theorem mem_union_left {x : α} {a : set α} (b : set α) : x ∈ a → x ∈ a ∪ b := or.inl
id ┴ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
src └─┘ └─┘ ┴ ┴ ┴ └────┘
typ ┴ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
267
268 theorem mem_union_right {x : α} {b : set α} (a : set α) : x ∈ b → x ∈ a ∪ b := or.inr
id ┴ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
src └─┘ └─┘ ┴ ┴ ┴ └────┘
typ ┴ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
269
270 theorem mem_or_mem_of_mem_union {x : α} {a b : set α} (H : x ∈ a ∪ b) : x ∈ a ∨ x ∈ b := H
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
271
272 theorem mem_union.elim {x : α} {a b : set α} {P : Prop}
id ┴ └─┘ ┴
src └─┘
typ ┴ └─┘ ┴
273 (H₁ : x ∈ a ∪ b) (H₂ : x ∈ a → P) (H₃ : x ∈ b → P) : P :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
274 or.elim H₁ H₂ H₃
id └─────┘ └┘ └┘ └┘
src └─────┘
typ └─────┘ └┘ └┘ └┘
275
276 theorem mem_union (x : α) (a b : set α) : x ∈ a ∪ b ↔ x ∈ a ∨ x ∈ b := iff.rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
277
278 @[simp] theorem mem_union_eq (x : α) (a b : set α) : x ∈ a ∪ b = (x ∈ a ∨ x ∈ b) := rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
279
280 @[simp] theorem union_self (a : set α) : a ∪ a = a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
281 ext (assume x, or_self _)
id └─┘ ┴ └─────┘
src └─┘ └─────┘
typ └─┘ ┴ └─────┘
282
283 @[simp] theorem union_empty (a : set α) : a ∪ ∅ = a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
284 ext (assume x, or_false _)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
285
286 @[simp] theorem empty_union (a : set α) : ∅ ∪ a = a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
287 ext (assume x, false_or _)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
288
289 theorem union_comm (a b : set α) : a ∪ b = b ∪ a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
290 ext (assume x, or.comm)
id └─┘ ┴ └─────┘
src └─┘ └─────┘
typ └─┘ ┴ └─────┘
291
292 theorem union_assoc (a b c : set α) : (a ∪ b) ∪ c = a ∪ (b ∪ c) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
293 ext (assume x, or.assoc)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
294
295 instance union_is_assoc : is_associative (set α) (∪) :=
id └────────────┘ └─┘ ┴ ┴
src └────────────┘ └─┘ ┴
typ └────────────┘ └─┘ ┴ ┴
296 ⟨union_assoc⟩
id └─────────┘
src └─────────┘
typ └─────────┘
297
298 instance union_is_comm : is_commutative (set α) (∪) :=
id └────────────┘ └─┘ ┴ ┴
src └────────────┘ └─┘ ┴
typ └────────────┘ └─┘ ┴ ┴
299 ⟨union_comm⟩
id └────────┘
src └────────┘
typ └────────┘
300
301 theorem union_left_comm (s₁ s₂ s₃ : set α) : s₁ ∪ (s₂ ∪ s₃) = s₂ ∪ (s₁ ∪ s₃) :=
id └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
302 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
303
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
304 theorem union_right_comm (s₁ s₂ s₃ : set α) : (s₁ ∪ s₂) ∪ s₃ = (s₁ ∪ s₃) ∪ s₂ :=
id └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
305 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
306
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
307 theorem union_eq_self_of_subset_left {s t : set α} (h : s ⊆ t) : s ∪ t = t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
308 by finish [subset_def, ext_iff, iff_def]
id └────────┘ └─────┘ └─────┘
src └──────┘└────────┘└┘└─────┘└┘└─────┘└─
typ └──────┘└────────┘└┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
309
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
310 theorem union_eq_self_of_subset_right {s t : set α} (h : t ⊆ s) : s ∪ t = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
311 by finish [subset_def, ext_iff, iff_def]
id └────────┘ └─────┘ └─────┘
src └──────┘└────────┘└┘└─────┘└┘└─────┘└─
typ └──────┘└────────┘└┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
312
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
313 @[simp] theorem subset_union_left (s t : set α) : s ⊆ s ∪ t := λ x, or.inl
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
src └─┘ ┴ ┴ └────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
doc └──┘
314
315 @[simp] theorem subset_union_right (s t : set α) : t ⊆ s ∪ t := λ x, or.inr
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
src └─┘ ┴ ┴ └────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘
doc └──┘
316
317 theorem union_subset {s t r : set α} (sr : s ⊆ r) (tr : t ⊆ r) : s ∪ t ⊆ r :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
318 by finish [subset_def, union_def]
id └────────┘ └───────┘
src └──────┘└────────┘└┘└───────┘└─
typ └──────┘└────────┘└┘└───────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └───────────────────────────────
319
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
320 @[simp] theorem union_subset_iff {s t u : set α} : s ∪ t ⊆ u ↔ s ⊆ u ∧ t ⊆ u :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
321 by finish [iff_def, subset_def]
id └─────┘ └────────┘
src └──────┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └─────────────────────────────
322
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
323 theorem union_subset_union {s₁ s₂ t₁ t₂ : set α} (h₁ : s₁ ⊆ s₂) (h₂ : t₁ ⊆ t₂) : s₁ ∪ t₁ ⊆ s₂ ∪ t₂ :=
id └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
324 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
325
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
326 theorem union_subset_union_left {s₁ s₂ : set α} (t) (h : s₁ ⊆ s₂) : s₁ ∪ t ⊆ s₂ ∪ t :=
id └─┘ ┴ └┘ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴
327 union_subset_union h (by refl)
id └────────────────┘ ┴
src └────────────────┘ └──┘
typ └────────────────┘ ┴ └──┘
doc └──┘
txt └──┘
par └──┘
st └───┘
328
329 theorem union_subset_union_right (s) {t₁ t₂ : set α} (h : t₁ ⊆ t₂) : s ∪ t₁ ⊆ s ∪ t₂ :=
id └─┘ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘
330 union_subset_union (by refl) h
id └────────────────┘ ┴
src └────────────────┘ └──┘
typ └────────────────┘ └──┘ ┴
doc └──┘
txt └──┘
par └──┘
st └───┘
331
332 lemma subset_union_of_subset_left {s t : set α} (h : s ⊆ t) (u : set α) : s ⊆ t ∪ u :=
id └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
333 subset.trans h (subset_union_left t u)
id └──────────┘ ┴ └───────────────┘ ┴ ┴
src └──────────┘ └───────────────┘
typ └──────────┘ ┴ └───────────────┘ ┴ ┴
334
335 lemma subset_union_of_subset_right {s u : set α} (h : s ⊆ u) (t : set α) : s ⊆ t ∪ u :=
id └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
336 subset.trans h (subset_union_right t u)
id └──────────┘ ┴ └────────────────┘ ┴ ┴
src └──────────┘ └────────────────┘
typ └──────────┘ ┴ └────────────────┘ ┴ ┴
337
338 @[simp] theorem union_empty_iff {s t : set α} : s ∪ t = ∅ ↔ s = ∅ ∧ t = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
339 ⟨by finish [ext_iff], by finish [ext_iff]⟩
id └─────┘ └─────┘
src └──────┘└─────┘┴ └──────┘└─────┘┴
typ └──────┘└─────┘┴ └──────┘└─────┘┴
doc └──────┘ ┴ └──────┘ ┴
txt └──────┘ ┴ └──────┘ ┴
par └──────┘ ┴ └──────┘ ┴
pid └┘ ┴ └┘ ┴
st └───────────────┘ └───────────────┘
340
341 /-! ### Lemmas about intersection -/
342
343 theorem inter_def {s₁ s₂ : set α} : s₁ ∩ s₂ = {a | a ∈ s₁ ∧ a ∈ s₂} := rfl
id └─┘ ┴ └┘ ┴ └┘ ┴ ┴┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ └─┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ └┘ ┴ └┘ ┴ ┴┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ └─┘
344
345 theorem mem_inter_iff (x : α) (a b : set α) : x ∈ a ∩ b ↔ x ∈ a ∧ x ∈ b := iff.rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
346
347 @[simp] theorem mem_inter_eq (x : α) (a b : set α) : x ∈ a ∩ b = (x ∈ a ∧ x ∈ b) := rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
348
349 theorem mem_inter {x : α} {a b : set α} (ha : x ∈ a) (hb : x ∈ b) : x ∈ a ∩ b :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
350 ⟨ha, hb⟩
id └┘ └┘
typ └┘ └┘
351
352 theorem mem_of_mem_inter_left {x : α} {a b : set α} (h : x ∈ a ∩ b) : x ∈ a :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
353 h.left
id ┴└───┘
src └───┘
typ ┴└───┘
354
355 theorem mem_of_mem_inter_right {x : α} {a b : set α} (h : x ∈ a ∩ b) : x ∈ b :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
356 h.right
id ┴└────┘
src └────┘
typ ┴└────┘
357
358 @[simp] theorem inter_self (a : set α) : a ∩ a = a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
359 ext (assume x, and_self _)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
360
361 @[simp] theorem inter_empty (a : set α) : a ∩ ∅ = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
362 ext (assume x, and_false _)
id └─┘ ┴ └───────┘
src └─┘ └───────┘
typ └─┘ ┴ └───────┘
363
364 @[simp] theorem empty_inter (a : set α) : ∅ ∩ a = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
365 ext (assume x, false_and _)
id └─┘ ┴ └───────┘
src └─┘ └───────┘
typ └─┘ ┴ └───────┘
366
367 theorem inter_comm (a b : set α) : a ∩ b = b ∩ a :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
368 ext (assume x, and.comm)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
369
370 theorem inter_assoc (a b c : set α) : (a ∩ b) ∩ c = a ∩ (b ∩ c) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
371 ext (assume x, and.assoc)
id └─┘ ┴ └───────┘
src └─┘ └───────┘
typ └─┘ ┴ └───────┘
372
373 instance inter_is_assoc : is_associative (set α) (∩) :=
id └────────────┘ └─┘ ┴ ┴
src └────────────┘ └─┘ ┴
typ └────────────┘ └─┘ ┴ ┴
374 ⟨inter_assoc⟩
id └─────────┘
src └─────────┘
typ └─────────┘
375
376 instance inter_is_comm : is_commutative (set α) (∩) :=
id └────────────┘ └─┘ ┴ ┴
src └────────────┘ └─┘ ┴
typ └────────────┘ └─┘ ┴ ┴
377 ⟨inter_comm⟩
id └────────┘
src └────────┘
typ └────────┘
378
379 theorem inter_left_comm (s₁ s₂ s₃ : set α) : s₁ ∩ (s₂ ∩ s₃) = s₂ ∩ (s₁ ∩ s₃) :=
id └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
380 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
381
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
382 theorem inter_right_comm (s₁ s₂ s₃ : set α) : (s₁ ∩ s₂) ∩ s₃ = (s₁ ∩ s₃) ∩ s₂ :=
id └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘ ┴ └┘
383 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
384
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
385 @[simp] theorem inter_subset_left (s t : set α) : s ∩ t ⊆ s := λ x H, and.left H
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
src └─┘ ┴ ┴ └──────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
doc └──┘
386
387 @[simp] theorem inter_subset_right (s t : set α) : s ∩ t ⊆ t := λ x H, and.right H
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───────┘ ┴
src └─┘ ┴ ┴ └───────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───────┘ ┴
doc └──┘
388
389 theorem subset_inter {s t r : set α} (rs : r ⊆ s) (rt : r ⊆ t) : r ⊆ s ∩ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
390 by finish [subset_def, inter_def]
id └────────┘ └───────┘
src └──────┘└────────┘└┘└───────┘└─
typ └──────┘└────────┘└┘└───────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └───────────────────────────────
391
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
392 @[simp] theorem subset_inter_iff {s t r : set α} : r ⊆ s ∩ t ↔ r ⊆ s ∧ r ⊆ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
393 ⟨λ h, ⟨subset.trans h (inter_subset_left _ _), subset.trans h (inter_subset_right _ _)⟩,
id ┴ └──────────┘ ┴ └───────────────┘ └──────────┘ ┴ └────────────────┘
src └──────────┘ └───────────────┘ └──────────┘ └────────────────┘
typ ┴ └──────────┘ ┴ └───────────────┘ └──────────┘ ┴ └────────────────┘
394 λ ⟨h₁, h₂⟩, subset_inter h₁ h₂⟩
id ┴└┘ └┘ └──────────┘
src └──────────┘
typ ┴└┘ └┘ └──────────┘
395
396 @[simp] theorem inter_univ (a : set α) : a ∩ univ = a :=
id └─┘ ┴ ┴ ┴ └──┘ ┴ ┴
src └─┘ ┴ └──┘ ┴
typ └─┘ ┴ ┴ ┴ └──┘ ┴ ┴
doc └──┘
397 ext (assume x, and_true _)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
398
399 @[simp] theorem univ_inter (a : set α) : univ ∩ a = a :=
id └─┘ ┴ └──┘ ┴ ┴ ┴ ┴
src └─┘ └──┘ ┴ ┴
typ └─┘ ┴ └──┘ ┴ ┴ ┴ ┴
doc └──┘
400 ext (assume x, true_and _)
id └─┘ ┴ └──────┘
src └─┘ └──────┘
typ └─┘ ┴ └──────┘
401
402 theorem inter_subset_inter_left {s t : set α} (u : set α) (H : s ⊆ t) : s ∩ u ⊆ t ∩ u :=
id └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
403 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
404
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
405 theorem inter_subset_inter_right {s t : set α} (u : set α) (H : s ⊆ t) : u ∩ s ⊆ u ∩ t :=
id └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
406 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
407
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
408 theorem inter_subset_inter {s₁ s₂ t₁ t₂ : set α} (h₁ : s₁ ⊆ t₁) (h₂ : s₂ ⊆ t₂) : s₁ ∩ s₂ ⊆ t₁ ∩ t₂ :=
id └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
409 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
410
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
411 theorem inter_eq_self_of_subset_left {s t : set α} (h : s ⊆ t) : s ∩ t = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
412 by finish [subset_def, ext_iff, iff_def]
id └────────┘ └─────┘ └─────┘
src └──────┘└────────┘└┘└─────┘└┘└─────┘└─
typ └──────┘└────────┘└┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
413
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
414 theorem inter_eq_self_of_subset_right {s t : set α} (h : t ⊆ s) : s ∩ t = t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
415 by finish [subset_def, ext_iff, iff_def]
id └────────┘ └─────┘ └─────┘
src └──────┘└────────┘└┘└─────┘└┘└─────┘└─
typ └──────┘└────────┘└┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
416
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
417 theorem union_inter_cancel_left {s t : set α} : (s ∪ t) ∩ s = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
418 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
419
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
420 theorem union_inter_cancel_right {s t : set α} : (s ∪ t) ∩ t = t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
421 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
422
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
423 /-! ### Distributivity laws -/
424
425 theorem inter_distrib_left (s t u : set α) : s ∩ (t ∪ u) = (s ∩ t) ∪ (s ∩ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
426 ext (assume x, and_or_distrib_left)
id └─┘ ┴ └─────────────────┘
src └─┘ └─────────────────┘
typ └─┘ ┴ └─────────────────┘
427
428 theorem inter_distrib_right (s t u : set α) : (s ∪ t) ∩ u = (s ∩ u) ∪ (t ∩ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
429 ext (assume x, or_and_distrib_right)
id └─┘ ┴ └──────────────────┘
src └─┘ └──────────────────┘
typ └─┘ ┴ └──────────────────┘
430
431 theorem union_distrib_left (s t u : set α) : s ∪ (t ∩ u) = (s ∪ t) ∩ (s ∪ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
432 ext (assume x, or_and_distrib_left)
id └─┘ ┴ └─────────────────┘
src └─┘ └─────────────────┘
typ └─┘ ┴ └─────────────────┘
433
434 theorem union_distrib_right (s t u : set α) : (s ∩ t) ∪ u = (s ∪ u) ∩ (t ∪ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
435 ext (assume x, and_or_distrib_right)
id └─┘ ┴ └──────────────────┘
src └─┘ └──────────────────┘
typ └─┘ ┴ └──────────────────┘
436
437 /-! ### Lemmas about `insert`
438
439 `insert α s` is the set `{α} ∪ s`. -/
440
441 theorem insert_def (x : α) (s : set α) : insert x s = { y | y = x ∨ y ∈ s } := rfl
id ┴ └─┘ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ └────┘ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
442
443 @[simp] theorem insert_of_has_insert (x : α) (s : set α) : has_insert.insert x s = insert x s := rfl
id ┴ └─┘ ┴ └───────────────┘ ┴ ┴ ┴ └────┘ ┴ ┴ └─┘
src └─┘ └───────────────┘ ┴ └────┘ └─┘
typ ┴ └─┘ ┴ └───────────────┘ ┴ ┴ ┴ └────┘ ┴ ┴ └─┘
doc └──┘
444
445 @[simp] theorem subset_insert (x : α) (s : set α) : s ⊆ insert x s :=
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴
src └─┘ ┴ └────┘
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴
doc └──┘
446 assume y ys, or.inr ys
id ┴ └┘ └────┘ └┘
src └────┘
typ ┴ └┘ └────┘ └┘
447
448 theorem mem_insert (x : α) (s : set α) : x ∈ insert x s :=
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴
src └─┘ ┴ └────┘
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴
449 or.inl rfl
id └────┘ └─┘
src └────┘ └─┘
typ └────┘ └─┘
450
451 theorem mem_insert_of_mem {x : α} {s : set α} (y : α) : x ∈ s → x ∈ insert y s := or.inr
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ └────┘
src └─┘ ┴ ┴ └────┘ └────┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ └────┘
452
453 theorem eq_or_mem_of_mem_insert {x a : α} {s : set α} : x ∈ insert a s → x = a ∨ x ∈ s := id
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
src └─┘ ┴ └────┘ ┴ ┴ ┴ └┘
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
454
455 theorem mem_of_mem_insert_of_ne {x a : α} {s : set α} (xin : x ∈ insert a s) : x ≠ a → x ∈ s :=
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └────┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
456 by finish [insert_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
457
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
458 @[simp] theorem mem_insert_iff {x a : α} {s : set α} : x ∈ insert a s ↔ (x = a ∨ x ∈ s) := iff.rfl
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ └────┘ ┴ ┴ ┴ ┴ └─────┘
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘
459
460 @[simp] theorem insert_eq_of_mem {a : α} {s : set α} (h : a ∈ s) : insert a s = s :=
id ┴ └─┘ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src └─┘ ┴ └────┘ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
doc └──┘
461 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
462
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
463 lemma ne_insert_of_not_mem {s : set α} (t : set α) {a : α} (h : a ∉ s) :
id └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src └─┘ └─┘ ┴
typ └─┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
464 s ≠ insert a t :=
id ┴ ┴ └────┘ ┴ ┴
src ┴ └────┘
typ ┴ ┴ └────┘ ┴ ┴
465 by { classical, contrapose! h, simp [h] }
id ┴
src └───────┘ └───────────┘ └────┘ └┘
typ └───────┘ └───────────┘ └────┘┴└┘
doc └───────┘ └───────────┘ └────┘ └┘
txt └───────┘ └───────────┘ └────┘ └┘
par └───────┘ └───────────┘ └────┘ └┘
pid ┴└┘ ┴┴ ┴┴
st └──────────┘└─────────────┘└─────────┘└┘
466
467 theorem insert_subset : insert a s ⊆ t ↔ (a ∈ t ∧ s ⊆ t) :=
id └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └────┘ ┴ ┴ ┴ ┴ ┴
typ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
468 by simp [subset_def, or_imp_distrib, forall_and_distrib]
id └────────┘ └────────────┘ └────────────────┘
src └────┘└────────┘└┘└────────────┘└┘└────────────────┘└─
typ └────┘└────────┘└┘└────────────┘└┘└────────────────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ ┴└
st └──────────────────────────────────────────────────────
469
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
470 theorem insert_subset_insert (h : s ⊆ t) : insert a s ⊆ insert a t :=
id ┴ ┴ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴
src ┴ └────┘ ┴ └────┘
typ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴
471 assume a', or.imp_right (@h a')
id └┘ └──────────┘ ┴ └┘
src └──────────┘
typ └┘ └──────────┘ ┴ └┘
472
473 theorem ssubset_insert {s : set α} {a : α} (h : a ∉ s) : s ⊂ insert a s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴
src └─┘ ┴ ┴ └────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴
474 by finish [ssubset_iff_subset_ne, ext_iff]
id └───────────────────┘ └─────┘
src └──────┘└───────────────────┘└┘└─────┘└─
typ └──────┘└───────────────────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └────────────────────────────────────────
475
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
476 theorem insert_comm (a b : α) (s : set α) : insert a (insert b s) = insert b (insert a s) :=
id ┴ └─┘ ┴ └────┘ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ └────┘ ┴ ┴
src └─┘ └────┘ └────┘ ┴ └────┘ └────┘
typ ┴ └─┘ ┴ └────┘ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ └────┘ ┴ ┴
477 ext $ by simp [or.left_comm]
id └─┘ └──────────┘
src └─┘ └────┘└──────────┘└─
typ └─┘ └────┘└──────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └────────────────────
478
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
479 theorem insert_union : insert a s ∪ t = insert a (s ∪ t) :=
id └────┘ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src └────┘ ┴ ┴ └────┘ ┴
typ └────┘ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
480 ext $ assume a, by simp [or.comm, or.left_comm]
id └─┘ ┴ └─────┘ └──────────┘
src └─┘ └────┘└─────┘└┘└──────────┘└─
typ └─┘ ┴ └────┘└─────┘└┘└──────────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └─────────────────────────────
481
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
482 @[simp] theorem union_insert : s ∪ insert a t = insert a (s ∪ t) :=
id ┴ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src ┴ └────┘ ┴ └────┘ ┴
typ ┴ ┴ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
doc └──┘
483 ext $ assume a, by simp [or.comm, or.left_comm]
id └─┘ ┴ └─────┘ └──────────┘
src └─┘ └────┘└─────┘└┘└──────────┘└─
typ └─┘ ┴ └────┘└─────┘└┘└──────────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └─────────────────────────────
484
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
485 theorem insert_nonempty (a : α) (s : set α) : (insert a s).nonempty :=
id ┴ └─┘ ┴ └────┘ ┴ ┴ └──────┘
src └─┘ └────┘ └──────┘
typ ┴ └─┘ ┴ └────┘ ┴ ┴ └──────┘
doc └──────┘
486 ⟨a, mem_insert a s⟩
id ┴ └────────┘ ┴ ┴
src └────────┘
typ ┴ └────────┘ ┴ ┴
487
488 -- useful in proofs by induction
489 theorem forall_of_forall_insert {P : α → Prop} {a : α} {s : set α} (h : ∀ x, x ∈ insert a s → P x) :
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src └─┘ ┴ └────┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
490 ∀ x, x ∈ s → P x :=
id ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴
491 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
492
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
493 theorem forall_insert_of_forall {P : α → Prop} {a : α} {s : set α} (h : ∀ x, x ∈ s → P x) (ha : P a) :
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
494 ∀ x, x ∈ insert a s → P x :=
id ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src ┴ └────┘
typ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
495 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
496
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
497 theorem bex_insert_iff {P : α → Prop} {a : α} {s : set α} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
498 (∃ x ∈ insert a s, P x) ↔ (∃ x ∈ s, P x) ∨ P a :=
id ┴ ┴ └────┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
src ┴ └────┘ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ └────┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
499 by finish [iff_def]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
500
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
501 theorem ball_insert_iff {P : α → Prop} {a : α} {s : set α} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
502 (∀ x ∈ insert a s, P x) ↔ P a ∧ (∀x ∈ s, P x) :=
id ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └────┘ ┴ ┴
typ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
503 by finish [iff_def]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
504
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
505 /-! ### Lemmas about singletons -/
506
507 theorem singleton_def (a : α) : ({a} : set α) = insert a ∅ := rfl
id ┴ ┴┴ └─┘ ┴ ┴ └────┘ ┴ ┴ └─┘
src ┴ └─┘ ┴ └────┘ ┴ └─┘
typ ┴ ┴┴ └─┘ ┴ ┴ └────┘ ┴ ┴ └─┘
508
509 @[simp] theorem mem_singleton_iff {a b : α} : a ∈ ({b} : set α) ↔ a = b :=
id ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ └─┘ ┴ ┴
typ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └──┘
510 by finish [singleton_def]
id └───────────┘
src └──────┘└───────────┘└─
typ └──────┘└───────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └───────────────────────
511
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
512 @[simp]
doc └──┘
513 lemma set_of_eq_eq_singleton {a : α} : {n | n = a} = {a} := set.ext $ λ n, (set.mem_singleton_iff).symm
id ┴ ┴┴ ┴ ┴ ┴ ┴ ┴┴ └─────┘ ┴ └───────────────────┘ └──┘
src ┴ ┴ ┴ ┴ └─────┘ └───────────────────┘ └──┘
typ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴┴ └─────┘ ┴ └───────────────────┘ └──┘
514
515 -- TODO: again, annotation needed
516 @[simp] theorem mem_singleton (a : α) : a ∈ ({a} : set α) := by finish
id ┴ ┴ ┴ ┴┴ └─┘ ┴
src ┴ ┴ └─┘ └──────
typ ┴ ┴ ┴ ┴┴ └─┘ ┴ └──────
doc └──┘ └──────
txt └──────
par └──────
pid └
st └───────
517
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
518 theorem eq_of_mem_singleton {x y : α} (h : x ∈ ({y} : set α)) : x = y :=
id ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴
src ┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴
519 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
520
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
521 @[simp] theorem singleton_eq_singleton_iff {x y : α} : {x} = ({y} : set α) ↔ x = y :=
id ┴ ┴┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ └─┘ ┴ ┴
typ ┴ ┴┴ ┴ ┴┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └──┘
522 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
523
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
524 theorem mem_singleton_of_eq {x y : α} (H : x = y) : x ∈ ({y} : set α) :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ └─┘ ┴
src ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ └─┘ ┴
525 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
526
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
527 theorem insert_eq (x : α) (s : set α) : insert x s = ({x} : set α) ∪ s :=
id ┴ └─┘ ┴ └────┘ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴
src └─┘ └────┘ ┴ ┴ └─┘ ┴
typ ┴ └─┘ ┴ └────┘ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴
528 by finish [ext_iff, or_comm]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
529
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
530 @[simp] theorem pair_eq_singleton (a : α) : ({a, a} : set α) = {a} :=
id ┴ ┴┴┴ ┴ └─┘ ┴ ┴ ┴┴
src ┴ ┴ └─┘ ┴ ┴
typ ┴ ┴┴┴ ┴ └─┘ ┴ ┴ ┴┴
doc └──┘
531 by finish
src └──────
typ └──────
doc └──────
txt └──────
par └──────
pid └
st └───────
532
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
533 @[simp] theorem singleton_nonempty (a : α) : ({a} : set α).nonempty := insert_nonempty _ _
id ┴ ┴┴ └─┘ ┴ └──────┘ └─────────────┘
src ┴ └─┘ └──────┘ └─────────────┘
typ ┴ ┴┴ └─┘ ┴ └──────┘ └─────────────┘
doc └──┘ └──────┘
534
535 @[simp] theorem singleton_subset_iff {a : α} {s : set α} : {a} ⊆ s ↔ a ∈ s :=
id ┴ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
536 ⟨λh, h (by simp), λh b e, by simp at e; simp [*]⟩
id ┴ ┴ ┴ ┴ ┴
src └──┘ └───────┘ └──────┘
typ ┴ ┴ └──┘ ┴ ┴ ┴ └───────┘ └──────┘
doc └──┘ └───────┘ └──────┘
txt └──┘ └───────┘ └──────┘
par └──┘ └───────┘ └──────┘
pid ┴└──┘ ┴└─┘
st └───┘ └──────────────────┘
537
538 theorem set_compr_eq_eq_singleton {a : α} : {b | b = a} = {a} :=
id ┴ ┴┴ ┴ ┴ ┴ ┴ ┴┴
src ┴ ┴ ┴ ┴
typ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴┴
539 ext $ by simp
id └─┘
src └─┘ └────
typ └─┘ └────
doc └────
txt └────
par └────
pid └
st └─────
540
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
541 @[simp] theorem union_singleton : s ∪ {a} = insert a s :=
id ┴ ┴ ┴┴ ┴ └────┘ ┴ ┴
src ┴ ┴ ┴ └────┘
typ ┴ ┴ ┴┴ ┴ └────┘ ┴ ┴
doc └──┘
542 by simp [singleton_def]
id └───────────┘
src └────┘└───────────┘└─
typ └────┘└───────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └─────────────────────
543
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
544 @[simp] theorem singleton_union : {a} ∪ s = insert a s :=
id ┴┴ ┴ ┴ ┴ └────┘ ┴ ┴
src ┴ ┴ ┴ └────┘
typ ┴┴ ┴ ┴ ┴ └────┘ ┴ ┴
doc └──┘
545 by rw [union_comm, union_singleton]
id └────────┘ └─────────────┘
src └──┘└────────┘└┘└─────────────┘└─
typ └──┘└────────┘└┘└─────────────┘└─
doc └──┘ └┘ └─
txt └──┘ └┘ └─
par └──┘ └┘ └─
pid └┘ └┘ ┴└
st └─────────────┘└───────────────┘┴└
546
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
547 theorem singleton_inter_eq_empty : {a} ∩ s = ∅ ↔ a ∉ s :=
id ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
548 by simp [eq_empty_iff_forall_not_mem]
id └─────────────────────────┘
src └────┘└─────────────────────────┘└─
typ └────┘└─────────────────────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────────────────────────
549
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
550 theorem inter_singleton_eq_empty : s ∩ {a} = ∅ ↔ a ∉ s :=
id ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
551 by rw [inter_comm, singleton_inter_eq_empty]
id └────────┘ └──────────────────────┘
src └──┘└────────┘└┘└──────────────────────┘└─
typ └──┘└────────┘└┘└──────────────────────┘└─
doc └──┘ └┘ └─
txt └──┘ └┘ └─
par └──┘ └┘ └─
pid └┘ └┘ ┴└
st └─────────────┘└────────────────────────┘┴└
552
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
553 lemma nmem_singleton_empty {s : set α} : s ∉ ({∅} : set (set α)) ↔ s.nonempty :=
id └─┘ ┴ ┴ ┴ ┴┴ └─┘ └─┘ ┴ ┴ ┴└───────┘
src └─┘ ┴ ┴┴ └─┘ └─┘ ┴ └───────┘
typ └─┘ ┴ ┴ ┴ ┴┴ └─┘ └─┘ ┴ ┴ ┴└───────┘
doc └───────┘
554 by rw [mem_singleton_iff, ← ne.def, ne_empty_iff_nonempty]
id └───────────────┘ └────┘ └───────────────────┘
src └──┘└───────────────┘└──┘└────┘└┘└───────────────────┘└─
typ └──┘└───────────────┘└──┘└────┘└┘└───────────────────┘└─
doc └──┘ └──┘ └┘ └─
txt └──┘ └──┘ └┘ └─
par └──┘ └──┘ └┘ └─
pid └┘ └──┘ └┘ ┴└
st └────────────────────┘└────────┘└─────────────────────┘┴└
555
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
556 instance unique_singleton (a : α) : unique ↥({a} : set α) :=
id ┴ └────┘ ┴ ┴┴ └─┘ ┴
src └────┘ ┴ ┴ └─┘
typ ┴ └────┘ ┴ ┴┴ └─┘ ┴
557 { default := ⟨a, mem_singleton a⟩,
id ┴ └───────────┘ ┴
src └───────────┘
typ ┴ └───────────┘ ┴
558 uniq :=
559 begin
st └─────
560 intros x,
src └──────┘
typ └──────┘
doc └──────┘
txt └──────┘
par └──────┘
pid └┘
st ───────────┘└─
561 apply subtype.coe_ext.2,
id └─────────────┘
src └────┘└─────────────┘└┘
typ └────┘└─────────────┘└┘
doc └────┘ └┘
txt └────┘ └┘
par └────┘ └┘
pid ┴ └┘
st ──────────────────────────┘└─
562 apply eq_of_mem_singleton (subtype.mem x),
id └─────────────────┘ └─────────┘ ┴
src └────┘└─────────────────┘┴ └─────────┘┴ ┴
typ └────┘└─────────────────┘┴ └─────────┘┴┴┴
doc └────┘ ┴ ┴ ┴
txt └────┘ ┴ ┴ ┴
par └────┘ ┴ ┴ ┴
pid ┴ ┴ ┴ ┴
st ────────────────────────────────────────────┘└─
563 end}
st ────┘
564
565 /-! ### Lemmas about sets defined as `{x ∈ s | p x}`. -/
566
567 theorem mem_sep {s : set α} {p : α → Prop} {x : α} (xs : x ∈ s) (px : p x) : x ∈ {x ∈ s | p x} :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
568 ⟨xs, px⟩
id └┘ └┘
typ └┘ └┘
569
570 @[simp] theorem mem_sep_eq {s : set α} {p : α → Prop} {x : α} : x ∈ {x ∈ s | p x} = (x ∈ s ∧ p x) := rfl
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
571
572 theorem mem_sep_iff {s : set α} {p : α → Prop} {x : α} : x ∈ {x ∈ s | p x} ↔ x ∈ s ∧ p x :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
573 iff.rfl
id └─────┘
src └─────┘
typ └─────┘
574
575 theorem eq_sep_of_subset {s t : set α} (ssubt : s ⊆ t) : s = {x ∈ t | x ∈ s} :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
576 by finish [ext_iff, iff_def, subset_def]
id └─────┘ └─────┘ └────────┘
src └──────┘└─────┘└┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
577
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
578 theorem sep_subset (s : set α) (p : α → Prop) : {x ∈ s | p x} ⊆ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
579 assume x, and.left
id ┴ └──────┘
src └──────┘
typ ┴ └──────┘
580
581 theorem forall_not_of_sep_empty {s : set α} {p : α → Prop} (h : {x ∈ s | p x} = ∅) :
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
582 ∀ x ∈ s, ¬ p x :=
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
583 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
584
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
585 @[simp] lemma sep_univ {α} {p : α → Prop} : {a ∈ (univ : set α) | p a} = {a | p a} :=
id ┴ ┴ └──┘ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
src ┴ └──┘ └─┘ ┴ ┴
typ ┴ ┴ └──┘ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
doc └──┘
586 set.ext $ by simp
id └─────┘
src └─────┘ └────
typ └─────┘ └────
doc └────
txt └────
par └────
pid └
st └─────
587
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
588 /-! ### Lemmas about complement -/
589
590 theorem mem_compl {s : set α} {x : α} (h : x ∉ s) : x ∈ -s := h
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴
591
592 lemma compl_set_of {α} (p : α → Prop) : - {a | p a} = { a | ¬ p a } := rfl
id ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
593
594 theorem not_mem_of_mem_compl {s : set α} {x : α} (h : x ∈ -s) : x ∉ s := h
id └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴
595
596 @[simp] theorem mem_compl_eq (s : set α) (x : α) : x ∈ -s = (x ∉ s) := rfl
id └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─┘
doc └──┘
597
598 theorem mem_compl_iff (s : set α) (x : α) : x ∈ -s ↔ x ∉ s := iff.rfl
id └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ ┴ ┴ └─────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─────┘
599
600 @[simp] theorem inter_compl_self (s : set α) : s ∩ -s = ∅ :=
id └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴
doc └──┘
601 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
602
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
603 @[simp] theorem compl_inter_self (s : set α) : -s ∩ s = ∅ :=
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴
doc └──┘
604 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
605
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
606 @[simp] theorem compl_empty : -(∅ : set α) = univ :=
id ┴ ┴ └─┘ ┴ ┴ └──┘
src ┴ ┴ └─┘ ┴ └──┘
typ ┴ ┴ └─┘ ┴ ┴ └──┘
doc └──┘
607 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
608
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
609 @[simp] theorem compl_union (s t : set α) : -(s ∪ t) = -s ∩ -t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
doc └──┘
610 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
611
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
612 @[simp] theorem compl_compl (s : set α) : -(-s) = s :=
id └─┘ ┴ ┴ ┴┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴┴ ┴ ┴
doc └──┘
613 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
614
src ─
typ ─
doc ─
txt ─
par ─
pid ─
st ─
615 -- ditto
src ────────┘
typ ────────┘
doc ────────┘
txt ────────┘
par ────────┘
pid ────────┘
st ────────┘
616 theorem compl_inter (s t : set α) : -(s ∩ t) = -s ∪ -t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
617 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
618
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
619 @[simp] theorem compl_univ : -(univ : set α) = ∅ :=
id ┴ └──┘ └─┘ ┴ ┴ ┴
src ┴ └──┘ └─┘ ┴ ┴
typ ┴ └──┘ └─┘ ┴ ┴ ┴
doc └──┘
620 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
621
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
622 lemma compl_empty_iff {s : set α} : -s = ∅ ↔ s = univ :=
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └──┘
src └─┘ ┴ ┴ ┴ ┴ ┴ └──┘
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └──┘
623 by { split, intro h, rw [←compl_compl s, h, compl_empty], intro h, rw [h, compl_univ] }
id └─────────┘ ┴ ┴ └─────────┘ ┴ └────────┘
src └───┘ └─────┘ └───┘└─────────┘┴ └┘ └┘└─────────┘┴ └─────┘ └──┘ └┘└────────┘└┘
typ └───┘ └─────┘ └───┘└─────────┘┴┴└┘┴└┘└─────────┘┴ └─────┘ └──┘┴└┘└────────┘└┘
doc └───┘ └─────┘ └───┘ ┴ └┘ └┘ ┴ └─────┘ └──┘ └┘ └┘
txt └───┘ └─────┘ └───┘ ┴ └┘ └┘ ┴ └─────┘ └──┘ └┘ └┘
par └───┘ └─────┘ └───┘ ┴ └┘ └┘ ┴ └─────┘ └──┘ └┘ └┘
pid └┘ └─┘ ┴ └┘ └┘ ┴ └┘ └┘ └┘ ┴┴
st └──────┘└───────┘└──────────────────┘└─┘└───────────┘└────────┘└─────┘└──────────┘┴┴└┘
624
625 lemma compl_univ_iff {s : set α} : -s = univ ↔ s = ∅ :=
id └─┘ ┴ ┴┴ ┴ └──┘ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ └──┘ ┴ ┴ ┴
typ └─┘ ┴ ┴┴ ┴ └──┘ ┴ ┴ ┴ ┴
626 by rw [←compl_empty_iff, compl_compl]
id └─────────────┘ └─────────┘
src └───┘└─────────────┘└┘└─────────┘└─
typ └───┘└─────────────┘└┘└─────────┘└─
doc └───┘ └┘ └─
txt └───┘ └┘ └─
par └───┘ └┘ └─
pid └─┘ └┘ ┴└
st └───────────────────┘└───────────┘┴└
627
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
628 lemma nonempty_compl {s : set α} : (-s : set α).nonempty ↔ s ≠ univ :=
id └─┘ ┴ ┴┴ └─┘ ┴ └──────┘ ┴ ┴ ┴ └──┘
src └─┘ ┴ └─┘ └──────┘ ┴ ┴ └──┘
typ └─┘ ┴ ┴┴ └─┘ ┴ └──────┘ ┴ ┴ ┴ └──┘
doc └──────┘
629 ne_empty_iff_nonempty.symm.trans $ not_congr $ compl_empty_iff
id └───────────────────┘└───┘└────┘ └───────┘ └─────────────┘
src └───────────────────┘└───┘└────┘ └───────┘ └─────────────┘
typ └───────────────────┘└───┘└────┘ └───────┘ └─────────────┘
630
631 theorem union_eq_compl_compl_inter_compl (s t : set α) : s ∪ t = -(-s ∩ -t) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
632 by simp [compl_inter, compl_compl]
id └─────────┘ └─────────┘
src └────┘└─────────┘└┘└─────────┘└─
typ └────┘└─────────┘└┘└─────────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └────────────────────────────────
633
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
634 theorem inter_eq_compl_compl_union_compl (s t : set α) : s ∩ t = -(-s ∪ -t) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴┴
635 by simp [compl_compl]
id └─────────┘
src └────┘└─────────┘└─
typ └────┘└─────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────────
636
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
637 @[simp] theorem union_compl_self (s : set α) : s ∪ -s = univ :=
id └─┘ ┴ ┴ ┴ ┴┴ ┴ └──┘
src └─┘ ┴ ┴ ┴ └──┘
typ └─┘ ┴ ┴ ┴ ┴┴ ┴ └──┘
doc └──┘
638 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
639
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
640 @[simp] theorem compl_union_self (s : set α) : -s ∪ s = univ :=
id └─┘ ┴ ┴┴ ┴ ┴ ┴ └──┘
src └─┘ ┴ ┴ ┴ └──┘
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ └──┘
doc └──┘
641 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
642
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
643 theorem compl_comp_compl : compl ∘ compl = @id (set α) :=
id └───┘ ┴ └───┘ ┴ └┘ └─┘ ┴
src └───┘ ┴ └───┘ ┴ └┘ └─┘
typ └───┘ ┴ └───┘ ┴ └┘ └─┘ ┴
644 funext compl_compl
id └────┘ └─────────┘
src └────┘ └─────────┘
typ └────┘ └─────────┘
645
646 theorem compl_subset_comm {s t : set α} : -s ⊆ t ↔ -t ⊆ s :=
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴
647 by haveI := classical.prop_decidable; exact
id └──────────────────────┘
src └───────┘└──────────────────────┘ └────┘
typ └───────┘└──────────────────────┘ └────┘
doc └───────┘ └────┘
txt └───────┘ └────┘
par └───────┘ └────┘
pid ┴└─┘ ┴
st └─────────────────────────────────────────
648 forall_congr (λ a, not_imp_comm)
id └──────────┘ └──────────┘
src └──────────┘┴ └──┘└──────────┘└─
typ └──────────┘┴ └──┘└──────────┘└─
doc ┴ └──┘ └─
txt ┴ └──┘ └─
par ┴ └──┘ └─
pid ┴ └──┘ ┴└
st ─────────────────────────────────
649
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
650 lemma compl_subset_compl {s t : set α} : -s ⊆ -t ↔ t ⊆ s :=
id └─┘ ┴ ┴┴ ┴ ┴┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴┴ ┴ ┴┴ ┴ ┴ ┴ ┴
651 by rw [compl_subset_comm, compl_compl]
id └───────────────┘ └─────────┘
src └──┘└───────────────┘└┘└─────────┘└─
typ └──┘└───────────────┘└┘└─────────┘└─
doc └──┘ └┘ └─
txt └──┘ └┘ └─
par └──┘ └┘ └─
pid └┘ └┘ ┴└
st └────────────────────┘└───────────┘┴└
652
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
653 theorem compl_subset_iff_union {s t : set α} : -s ⊆ t ↔ s ∪ t = univ :=
id └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──┘
src └─┘ ┴ ┴ ┴ ┴ ┴ └──┘
typ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──┘
654 iff.symm $ eq_univ_iff_forall.trans $ forall_congr $ λ a,
id └──────┘ └────────────────┘└────┘ └──────────┘ ┴
src └──────┘ └────────────────┘└────┘ └──────────┘
typ └──────┘ └────────────────┘└────┘ └──────────┘ ┴
655 by haveI := classical.prop_decidable; exact or_iff_not_imp_left
id └──────────────────────┘ └─────────────────┘
src └───────┘└──────────────────────┘ └────┘└─────────────────┘└
typ └───────┘└──────────────────────┘ └────┘└─────────────────┘└
doc └───────┘ └────┘ └
txt └───────┘ └────┘ └
par └───────┘ └────┘ └
pid ┴└─┘ ┴ └
st └─────────────────────────────────────────────────────────────
656
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
657 theorem subset_compl_comm {s t : set α} : s ⊆ -t ↔ t ⊆ -s :=
id └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴
658 forall_congr $ λ a, imp_not_comm
id └──────────┘ ┴ └──────────┘
src └──────────┘ └──────────┘
typ └──────────┘ ┴ └──────────┘
659
660 theorem subset_compl_iff_disjoint {s t : set α} : s ⊆ -t ↔ s ∩ t = ∅ :=
id └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
661 iff.trans (forall_congr $ λ a, and_imp.symm) subset_empty_iff
id └───────┘ └──────────┘ ┴ └─────┘└───┘ └──────────────┘
src └───────┘ └──────────┘ └─────┘└───┘ └──────────────┘
typ └───────┘ └──────────┘ ┴ └─────┘└───┘ └──────────────┘
662
663 theorem inter_subset (a b c : set α) : a ∩ b ⊆ c ↔ a ⊆ -b ∪ c :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
664 begin
st └─────
665 haveI := classical.prop_decidable,
id └──────────────────────┘
src └───────┘└──────────────────────┘
typ └───────┘└──────────────────────┘
doc └───────┘
txt └───────┘
par └───────┘
pid ┴└─┘
st ──────────────────────────────────┘└─
666 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
667 { intros h x xa, by_cases h' : x ∈ b, simp [h ⟨xa, h'⟩], simp [h'] },
id ┴ ┴ ┴ ┴ └┘ └┘ └┘
src └───────────┘ └───────┘ └─┘ ┴┴┴ └────┘ ┴ └┘ └┘ └────┘ └┘
typ └───────────┘ └───────┘ └─┘┴┴┴┴┴ └────┘┴┴ └┘└┘└┘└┘ └────┘└┘└┘
doc └───────────┘ └───────┘ └─┘ ┴ ┴ └────┘ ┴ └┘ └┘ └────┘ └┘
txt └───────────┘ └───────┘ └─┘ ┴ ┴ └────┘ ┴ └┘ └┘ └────┘ └┘
par └───────────┘ └───────┘ └─┘ ┴ ┴ └────┘ ┴ └┘ └┘ └────┘ └┘
pid └─────┘ ┴ └─┘ ┴ ┴ ┴┴ ┴ └┘ └┘ ┴┴ ┴┴
st ───┘└───────────┘└───────────────────┘└─────────────────┘└──────────┘└┘└
668 intros h x, rintro ⟨xa, xb⟩, cases h xa, contradiction, assumption
id ┴ └┘
src └────────┘ └─────────────┘ └────┘ ┴ └───────────┘ └─────────┘
typ └────────┘ └─────────────┘ └────┘┴┴└┘ └───────────┘ └─────────┘
doc └────────┘ └─────────────┘ └────┘ ┴ └───────────┘ └─────────┘
txt └────────┘ └─────────────┘ └────┘ ┴ └───────────┘ └─────────┘
par └────────┘ └─────────────┘ └────┘ ┴ └───────────┘ └─────────┘
pid └──┘ └───────┘ ┴ ┴ ┴
st ───────────┘└───────────────┘└──────────┘└─────────────┘└───────────┘
669 end
st └─┘
670
671 /-! ### Lemmas about set difference -/
672
673 theorem diff_eq (s t : set α) : s \ t = s ∩ -t := rfl
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ └─┘
src └─┘ ┴ ┴ ┴ ┴ └─┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ └─┘
674
675 @[simp] theorem mem_diff {s t : set α} (x : α) : x ∈ s \ t ↔ x ∈ s ∧ x ∉ t := iff.rfl
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘
676
677 theorem mem_diff_of_mem {s t : set α} {x : α} (h1 : x ∈ s) (h2 : x ∉ t) : x ∈ s \ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
678 ⟨h1, h2⟩
id └┘ └┘
typ └┘ └┘
679
680 theorem mem_of_mem_diff {s t : set α} {x : α} (h : x ∈ s \ t) : x ∈ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
681 h.left
id ┴└───┘
src └───┘
typ ┴└───┘
682
683 theorem not_mem_of_mem_diff {s t : set α} {x : α} (h : x ∈ s \ t) : x ∉ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
684 h.right
id ┴└────┘
src └────┘
typ ┴└────┘
685
686 theorem nonempty_diff {s t : set α} : (s \ t).nonempty ↔ ¬ (s ⊆ t) :=
id └─┘ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └──────┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
doc └──────┘
687 ⟨λ ⟨x, xs, xt⟩, not_subset.2 ⟨x, xs, xt⟩,
id ┴┴ └┘ └┘ └────────┘┴
src └────────┘┴
typ ┴┴ └┘ └┘ └────────┘┴
688 λ h, let ⟨x, xs, xt⟩ := not_subset.1 h in ⟨x, xs, xt⟩⟩
id ┴ └─┘ ┴ └┘ └┘ └────────┘┴ ┴
src └────────┘┴
typ ┴ └─┘ ┴ └┘ └┘ └────────┘┴ ┴
689
690 theorem union_diff_cancel {s t : set α} (h : s ⊆ t) : s ∪ (t \ s) = t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
691 by finish [ext_iff, iff_def, subset_def]
id └─────┘ └─────┘ └────────┘
src └──────┘└─────┘└┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
692
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
693 theorem union_diff_cancel_left {s t : set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ s = t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
694 by finish [ext_iff, iff_def, subset_def]
id └─────┘ └─────┘ └────────┘
src └──────┘└─────┘└┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
695
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
696 theorem union_diff_cancel_right {s t : set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ t = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
697 by finish [ext_iff, iff_def, subset_def]
id └─────┘ └─────┘ └────────┘
src └──────┘└─────┘└┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
698
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
699 theorem union_diff_left {s t : set α} : (s ∪ t) \ s = t \ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
700 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
701
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
702 theorem union_diff_right {s t : set α} : (s ∪ t) \ t = s \ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
703 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
704
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
705 theorem union_diff_distrib {s t u : set α} : (s ∪ t) \ u = s \ u ∪ t \ u :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
706 inter_distrib_right _ _ _
id └─────────────────┘
src └─────────────────┘
typ └─────────────────┘
707
708 theorem inter_union_distrib_left {s t u : set α} : s ∩ (t ∪ u) = (s ∩ t) ∪ (s ∩ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
709 set.ext $ λ _, and_or_distrib_left
id └─────┘ ┴ └─────────────────┘
src └─────┘ └─────────────────┘
typ └─────┘ ┴ └─────────────────┘
710
711 theorem inter_union_distrib_right {s t u : set α} : (s ∩ t) ∪ u = (s ∪ u) ∩ (t ∪ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
712 set.ext $ λ _, and_or_distrib_right
id └─────┘ ┴ └──────────────────┘
src └─────┘ └──────────────────┘
typ └─────┘ ┴ └──────────────────┘
713
714 theorem union_inter_distrib_left {s t u : set α} : s ∪ (t ∩ u) = (s ∪ t) ∩ (s ∪ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
715 set.ext $ λ _, or_and_distrib_left
id └─────┘ ┴ └─────────────────┘
src └─────┘ └─────────────────┘
typ └─────┘ ┴ └─────────────────┘
716
717 theorem union_inter_distrib_right {s t u : set α} : (s ∪ t) ∩ u = (s ∩ u) ∪ (t ∩ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
718 set.ext $ λ _, or_and_distrib_right
id └─────┘ ┴ └──────────────────┘
src └─────┘ └──────────────────┘
typ └─────┘ ┴ └──────────────────┘
719
720 theorem inter_diff_assoc (a b c : set α) : (a ∩ b) \ c = a ∩ (b \ c) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
721 inter_assoc _ _ _
id └─────────┘
src └─────────┘
typ └─────────┘
722
723 theorem inter_diff_self (a b : set α) : a ∩ (b \ a) = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
724 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
725
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
726 theorem inter_union_diff (s t : set α) : (s ∩ t) ∪ (s \ t) = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
727 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
728
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
729 theorem diff_subset (s t : set α) : s \ t ⊆ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
730 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
731
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
732 theorem diff_subset_diff {s₁ s₂ t₁ t₂ : set α} : s₁ ⊆ s₂ → t₂ ⊆ t₁ → s₁ \ t₁ ⊆ s₂ \ t₂ :=
id └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘ └┘ ┴ └┘ ┴ └┘ ┴ └┘
733 by finish [subset_def]
id └────────┘
src └──────┘└────────┘└─
typ └──────┘└────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └────────────────────
734
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
735 theorem diff_subset_diff_left {s₁ s₂ t : set α} (h : s₁ ⊆ s₂) : s₁ \ t ⊆ s₂ \ t :=
id └─┘ ┴ └┘ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴
736 diff_subset_diff h (by refl)
id └──────────────┘ ┴
src └──────────────┘ └──┘
typ └──────────────┘ ┴ └──┘
doc └──┘
txt └──┘
par └──┘
st └───┘
737
738 theorem diff_subset_diff_right {s t u : set α} (h : t ⊆ u) : s \ u ⊆ s \ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
739 diff_subset_diff (subset.refl s) h
id └──────────────┘ └─────────┘ ┴ ┴
src └──────────────┘ └─────────┘
typ └──────────────┘ └─────────┘ ┴ ┴
740
741 theorem compl_eq_univ_diff (s : set α) : -s = univ \ s :=
id └─┘ ┴ ┴┴ ┴ └──┘ ┴ ┴
src └─┘ ┴ ┴ └──┘ ┴
typ └─┘ ┴ ┴┴ ┴ └──┘ ┴ ┴
742 by finish [ext_iff]
id └─────┘
src └──────┘└─────┘└─
typ └──────┘└─────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └─────────────────
743
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
744 @[simp] lemma empty_diff {α : Type*} (s : set α) : (∅ \ s : set α) = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
doc └──┘
745 eq_empty_of_subset_empty $ assume x ⟨hx, _⟩, hx
id └──────────────────────┘ ┴ ┴└┘
src └──────────────────────┘
typ └──────────────────────┘ ┴ ┴└┘
746
747 theorem diff_eq_empty {s t : set α} : s \ t = ∅ ↔ s ⊆ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
748 ⟨assume h x hx, classical.by_contradiction $ assume : x ∉ t, show x ∈ (∅ : set α), from h ▸ ⟨hx, this⟩,
id ┴ ┴ └┘ └────────────────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ └──┘
src └────────────────────────┘ ┴ ┴ ┴ └─┘ ┴
typ ┴ ┴ └┘ └────────────────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ └──┘
749 assume h, eq_empty_of_subset_empty $ assume x ⟨hx, hnx⟩, hnx $ h hx⟩
id ┴ └──────────────────────┘ ┴ ┴└┘ └─┘ ┴
src └──────────────────────┘
typ ┴ └──────────────────────┘ ┴ ┴└┘ └─┘ ┴
750
751 @[simp] theorem diff_empty {s : set α} : s \ ∅ = s :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
752 ext $ assume x, ⟨assume ⟨hx, _⟩, hx, assume h, ⟨h, not_false⟩⟩
id └─┘ ┴ ┴└┘ ┴ ┴ └───────┘
src └─┘ └───────┘
typ └─┘ ┴ ┴└┘ ┴ ┴ └───────┘
753
754 theorem diff_diff {u : set α} : s \ t \ u = s \ (t ∪ u) :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
755 ext $ by simp [not_or_distrib, and.comm, and.left_comm]
id └─┘ └────────────┘ └──────┘ └───────────┘
src └─┘ └────┘└────────────┘└┘└──────┘└┘└───────────┘└─
typ └─┘ └────┘└────────────┘└┘└──────┘└┘└───────────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ ┴└
st └───────────────────────────────────────────────
756
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
757 lemma diff_subset_iff {s t u : set α} : s \ t ⊆ u ↔ s ⊆ t ∪ u :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
758 ⟨assume h x xs, classical.by_cases or.inl (assume nxt, or.inr (h ⟨xs, nxt⟩)),
id ┴ ┴ └┘ └────────────────┘ └────┘ └─┘ └────┘ ┴ └┘ └─┘
src └────────────────┘ └────┘ └────┘
typ ┴ ┴ └┘ └────────────────┘ └────┘ └─┘ └────┘ ┴ └┘ └─┘
759 assume h x ⟨xs, nxt⟩, or.resolve_left (h xs) nxt⟩
id ┴ ┴ ┴└┘ └─┘ └─────────────┘ ┴
src └─────────────┘
typ ┴ ┴ ┴└┘ └─┘ └─────────────┘ ┴
760
761 lemma subset_diff_union (s t : set α) : s ⊆ (s \ t) ∪ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
762 by rw [union_comm, ←diff_subset_iff]
id └────────┘ └─────────────┘
src └──┘└────────┘└─┘└─────────────┘└─
typ └──┘└────────┘└─┘└─────────────┘└─
doc └──┘ └─┘ └─
txt └──┘ └─┘ └─
par └──┘ └─┘ └─
pid └┘ └─┘ ┴└
st └─────────────┘└────────────────┘┴└
763
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
764 @[simp] lemma diff_singleton_subset_iff {x : α} {s t : set α} : s \ {x} ⊆ t ↔ s ⊆ insert x t :=
id ┴ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ └────┘
typ ┴ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴
doc └──┘
765 by { rw [←union_singleton, union_comm], apply diff_subset_iff }
id └─────────────┘ └────────┘ └─────────────┘
src └───┘└─────────────┘└┘└────────┘┴ └────┘└─────────────┘┴
typ └───┘└─────────────┘└┘└────────┘┴ └────┘└─────────────┘┴
doc └───┘ └┘ ┴ └────┘ ┴
txt └───┘ └┘ ┴ └────┘ ┴
par └───┘ └┘ ┴ └────┘ ┴
pid └─┘ └┘ ┴ ┴ ┴
st └─────────────────────┘└──────────┘└───────────────────────┘└┘
766
767 lemma subset_insert_diff_singleton (x : α) (s : set α) : s ⊆ insert x (s \ {x}) :=
id ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴┴
src └─┘ ┴ └────┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴┴
768 by rw [←diff_singleton_subset_iff]
id └───────────────────────┘
src └───┘└───────────────────────┘└─
typ └───┘└───────────────────────┘└─
doc └───┘ └─
txt └───┘ └─
par └───┘ └─
pid └─┘ ┴└
st └─────────────────────────────┘┴└
769
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
770 lemma diff_subset_comm {s t u : set α} : s \ t ⊆ u ↔ s \ u ⊆ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
771 by rw [diff_subset_iff, diff_subset_iff, union_comm]
id └─────────────┘ └─────────────┘ └────────┘
src └──┘└─────────────┘└┘└─────────────┘└┘└────────┘└─
typ └──┘└─────────────┘└┘└─────────────┘└┘└────────┘└─
doc └──┘ └┘ └┘ └─
txt └──┘ └┘ └┘ └─
par └──┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────┘└───────────────┘└──────────┘┴└
772
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
773 @[simp] theorem insert_diff_of_mem (s) (h : a ∈ t) : insert a s \ t = s \ t :=
id ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └────┘ ┴ ┴ ┴
typ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
774 ext $ by intro; constructor; simp [or_imp_distrib, h] {contextual := tt}
id └─┘ └────────────┘ ┴ └┘
src └─┘ └───┘ └─────────┘ └────┘└────────────┘└┘ └┘ └────────────┘└┘└─
typ └─┘ └───┘ └─────────┘ └────┘└────────────┘└┘┴└┘ └────────────┘└┘└─
doc └───┘ └─────────┘ └────┘ └┘ └┘ └────────────┘ └─
txt └───┘ └─────────┘ └────┘ └┘ └┘ └────────────┘ └─
par └───┘ └─────────┘ └────┘ └┘ └┘ └────────────┘ └─
pid ┴┴ └┘ ┴┴ └────────────┘ ┴└
st └────────────────────────────────────────────────────────────────
775
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
776 theorem insert_diff_of_not_mem (s) (h : a ∉ t) : insert a s \ t = insert a (s \ t) :=
id ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
src ┴ └────┘ ┴ ┴ └────┘ ┴
typ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ ┴
777 begin
st └─────
778 classical,
src └───────┘
typ └───────┘
doc └───────┘
txt └───────┘
par └───────┘
st ──────────┘└─
779 ext x,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
pid └┘
st ──────┘└─
780 by_cases h' : x ∈ t,
id ┴ ┴ ┴
src └───────┘ └─┘ ┴┴┴
typ └───────┘ └─┘┴┴┴┴┴
doc └───────┘ └─┘ ┴ ┴
txt └───────┘ └─┘ ┴ ┴
par └───────┘ └─┘ ┴ ┴
pid ┴ └─┘ ┴ ┴
st ────────────────────┘└─
781 { have : x ≠ a,
id ┴ ┴ ┴
src └─────┘ ┴┴┴
typ └─────┘┴┴┴┴┴
doc └─────┘ ┴ ┴
txt └─────┘ ┴ ┴
par └─────┘ ┴ ┴
pid └───┘└┘ ┴ ┴
st ───┘└──────────┘└─
782 { assume H,
src └──────┘
typ └──────┘
doc └──────┘
txt └──────┘
par └──────┘
pid └──────┘
st ─────┘└──────┘└─
783 rw H at h',
id ┴
src └─┘ └────┘
typ └─┘┴└────┘
doc └─┘ └────┘
txt └─┘ └────┘
par └─┘ └────┘
pid ┴ └────┘
st ───────────────┘└─
784 exact h h' },
id ┴ └┘
src └────┘ ┴ ┴
typ └────┘┴┴└┘┴
doc └────┘ ┴ ┴
txt └────┘ ┴ ┴
par └────┘ ┴ ┴
pid ┴ ┴ ┴
st ────────────────┘└┘└
785 simp [h, h', this] },
id ┴ └┘ └──┘
src └────┘ └┘ └┘ └┘
typ └────┘┴└┘└┘└┘└──┘└┘
doc └────┘ └┘ └┘ └┘
txt └────┘ └┘ └┘ └┘
par └────┘ └┘ └┘ └┘
pid ┴┴ └┘ └┘ ┴┴
st ──────────────────────┘└┘└
786 { simp [h, h'] }
id ┴ └┘
src └────┘ └┘ └┘
typ └────┘┴└┘└┘└┘
doc └────┘ └┘ └┘
txt └────┘ └┘ └┘
par └────┘ └┘ └┘
pid ┴┴ └┘ ┴┴
st ────────────────┘└─
787 end
st ──┘
788
789 theorem union_diff_self {s t : set α} : s ∪ (t \ s) = s ∪ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
790 by finish [ext_iff, iff_def]
id └─────┘ └─────┘
src └──────┘└─────┘└┘└─────┘└─
typ └──────┘└─────┘└┘└─────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────
791
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
792 theorem diff_union_self {s t : set α} : (s \ t) ∪ t = s ∪ t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
793 by rw [union_comm, union_diff_self, union_comm]
id └────────┘ └─────────────┘ └────────┘
src └──┘└────────┘└┘└─────────────┘└┘└────────┘└─
typ └──┘└────────┘└┘└─────────────┘└┘└────────┘└─
doc └──┘ └┘ └┘ └─
txt └──┘ └┘ └┘ └─
par └──┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └─────────────┘└───────────────┘└──────────┘┴└
794
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
795 theorem diff_inter_self {a b : set α} : (b \ a) ∩ a = ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
796 ext $ by simp [iff_def] {contextual:=tt}
id └─┘ └─────┘ └┘
src └─┘ └────┘└─────┘└┘ └──────────┘└┘└─
typ └─┘ └────┘└─────┘└┘ └──────────┘└┘└─
doc └────┘ └┘ └──────────┘ └─
txt └────┘ └┘ └──────────┘ └─
par └────┘ └┘ └──────────┘ └─
pid ┴┴ ┴┴ └──────────┘ ┴└
st └────────────────────────────────
797
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
798 theorem diff_eq_self {s t : set α} : s \ t = s ↔ t ∩ s ⊆ ∅ :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
799 by finish [ext_iff, iff_def, subset_def]
id └─────┘ └─────┘ └────────┘
src └──────┘└─────┘└┘└─────┘└┘└────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └──────────────────────────────────────
800
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
801 @[simp] theorem diff_singleton_eq_self {a : α} {s : set α} (h : a ∉ s) : s \ {a} = s :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴
doc └──┘
802 diff_eq_self.2 $ by simp [singleton_inter_eq_empty.2 h]
id └──────────┘┴ └──────────────────────┘ ┴
src └──────────┘┴ └────┘└──────────────────────┘└─┘ └─
typ └──────────┘┴ └────┘└──────────────────────┘└─┘┴└─
doc └────┘ └─┘ └─
txt └────┘ └─┘ └─
par └────┘ └─┘ └─
pid ┴┴ └─┘ ┴└
st └────────────────────────────────────
803
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
804 @[simp] theorem insert_diff_singleton {a : α} {s : set α} :
id ┴ └─┘ ┴
src └─┘
typ ┴ └─┘ ┴
doc └──┘
805 insert a (s \ {a}) = insert a s :=
id └────┘ ┴ ┴ ┴ ┴┴ ┴ └────┘ ┴ ┴
src └────┘ ┴ ┴ ┴ └────┘
typ └────┘ ┴ ┴ ┴ ┴┴ ┴ └────┘ ┴ ┴
806 by simp [insert_eq, union_diff_self, -union_singleton, -singleton_union]
id └───────┘ └─────────────┘
src └────┘└───────┘└┘└─────────────┘└─────────────────────────────────────
typ └────┘└───────┘└┘└─────────────┘└─────────────────────────────────────
doc └────┘ └┘ └─────────────────────────────────────
txt └────┘ └┘ └─────────────────────────────────────
par └────┘ └┘ └─────────────────────────────────────
pid ┴┴ └┘ └───────────────────────────────────┘└
st └──────────────────────────────────────────────────────────────────────
807
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
808 @[simp] lemma diff_self {s : set α} : s \ s = ∅ := ext $ by simp
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ └─┘ └────
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ └────
doc └──┘ └────
txt └────
par └────
pid └
st └─────
809
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
810 lemma mem_diff_singleton {s s' : set α} {t : set (set α)} : s ∈ t \ {s'} ↔ (s ∈ t ∧ s ≠ s') :=
id └─┘ ┴ └─┘ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
src └─┘ └─┘ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ └─┘ ┴ └─┘ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
811 by simp
src └────
typ └────
doc └────
txt └────
par └────
pid └
st └─────
812
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
813 lemma mem_diff_singleton_empty {s : set α} {t : set (set α)} :
id └─┘ ┴ └─┘ └─┘ ┴
src └─┘ └─┘ └─┘
typ └─┘ ┴ └─┘ └─┘ ┴
814 s ∈ t \ {∅} ↔ (s ∈ t ∧ s.nonempty) :=
id ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
src ┴ ┴ ┴┴ ┴ ┴ ┴ └───────┘
typ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴└───────┘
doc └───────┘
815 mem_diff_singleton.trans $ and_congr iff.rfl ne_empty_iff_nonempty
id └────────────────┘└────┘ └───────┘ └─────┘ └───────────────────┘
src └────────────────┘└────┘ └───────┘ └─────┘ └───────────────────┘
typ └────────────────┘└────┘ └───────┘ └─────┘ └───────────────────┘
816
817 /-! ### Powerset -/
818
819 theorem mem_powerset {x s : set α} (h : x ⊆ s) : x ∈ powerset s := h
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴
src └─┘ ┴ ┴ └──────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴
820
821 theorem subset_of_mem_powerset {x s : set α} (h : x ∈ powerset s) : x ⊆ s := h
id └─┘ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └──────┘ ┴
typ └─┘ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
822
823 theorem mem_powerset_iff (x s : set α) : x ∈ powerset s ↔ x ⊆ s := iff.rfl
id └─┘ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ └──────┘ ┴ ┴ └─────┘
typ └─┘ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ └─────┘
824
825 /-! ### Inverse image -/
826
827 /-- The preimage of `s : set β` by `f : α → β`, written `f ⁻¹' s`,
828 is the set of `x : α` such that `f x ∈ s`. -/
829 def preimage {α : Type u} {β : Type v} (f : α → β) (s : set β) : set α := {x | f x ∈ s}
id ┴ ┴ └─┘ ┴ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴
src └─┘ └─┘ ┴ ┴
typ ┴ ┴ └─┘ ┴ └─┘ ┴ ┴┴ ┴ ┴ ┴ ┴
830
831 infix ` ⁻¹' `:80 := preimage
id └──────┘
src └──────┘
typ └──────┘
doc └──────┘
832
833 section preimage
834 variables {f : α → β} {g : β → γ}
835
836 @[simp] theorem preimage_empty : f ⁻¹' ∅ = ∅ := rfl
id ┴ └─┘ ┴ ┴ ┴ └─┘
src └─┘ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ └─┘
doc └──┘ └─┘
837
838 @[simp] theorem mem_preimage {s : set β} {a : α} : (a ∈ f ⁻¹' s) ↔ (f a ∈ s) := iff.rfl
id └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ └─┘ ┴ ┴ └─────┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘ └─┘
839
840 theorem preimage_mono {s t : set β} (h : s ⊆ t) : f ⁻¹' s ⊆ f ⁻¹' t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴
src └─┘ ┴ └─┘ ┴ └─┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴
doc └─┘ └─┘
841 assume x hx, h hx
id ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ └┘
842
843 @[simp] theorem preimage_univ : f ⁻¹' univ = univ := rfl
id ┴ └─┘ └──┘ ┴ └──┘ └─┘
src └─┘ └──┘ ┴ └──┘ └─┘
typ ┴ └─┘ └──┘ ┴ └──┘ └─┘
doc └──┘ └─┘
844
845 @[simp] theorem subset_preimage_univ {s : set α} : s ⊆ f ⁻¹' univ := subset_univ _
id └─┘ ┴ ┴ ┴ ┴ └─┘ └──┘ └─────────┘
src └─┘ ┴ └─┘ └──┘ └─────────┘
typ └─┘ ┴ ┴ ┴ ┴ └─┘ └──┘ └─────────┘
doc └──┘ └─┘
846
847 @[simp] theorem preimage_inter {s t : set β} : f ⁻¹' (s ∩ t) = f ⁻¹' s ∩ f ⁻¹' t := rfl
id └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
src └─┘ └─┘ ┴ ┴ └─┘ ┴ └─┘ └─┘
typ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
doc └──┘ └─┘ └─┘ └─┘
848
849 @[simp] theorem preimage_union {s t : set β} : f ⁻¹' (s ∪ t) = f ⁻¹' s ∪ f ⁻¹' t := rfl
id └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
src └─┘ └─┘ ┴ ┴ └─┘ ┴ └─┘ └─┘
typ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
doc └──┘ └─┘ └─┘ └─┘
850
851 @[simp] theorem preimage_compl {s : set β} : f ⁻¹' (- s) = - (f ⁻¹' s) := rfl
id └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ └─┘
src └─┘ └─┘ ┴ ┴ ┴ └─┘ └─┘
typ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ └─┘
doc └──┘ └─┘ └─┘
852
853 @[simp] theorem preimage_diff (f : α → β) (s t : set β) :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
doc └──┘
854 f ⁻¹' (s \ t) = f ⁻¹' s \ f ⁻¹' t := rfl
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
src └─┘ ┴ ┴ └─┘ ┴ └─┘ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘
doc └─┘ └─┘ └─┘
855
856 @[simp] theorem preimage_set_of_eq {p : α → Prop} {f : β → α} : f ⁻¹' {a | p a} = {a | p (f a)} :=
id ┴ ┴ ┴ ┴ └─┘ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ └─┘ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
doc └──┘ └─┘
857 rfl
id └─┘
src └─┘
typ └─┘
858
859 @[simp] theorem preimage_id {s : set α} : id ⁻¹' s = s := rfl
id └─┘ ┴ └┘ └─┘ ┴ ┴ ┴ └─┘
src └─┘ └┘ └─┘ ┴ └─┘
typ └─┘ ┴ └┘ └─┘ ┴ ┴ ┴ └─┘
doc └──┘ └─┘
860
861 theorem preimage_comp {s : set γ} : (g ∘ f) ⁻¹' s = f ⁻¹' (g ⁻¹' s) := rfl
id └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘ ┴ └─┘
src └─┘ ┴ └─┘ ┴ └─┘ └─┘ └─┘
typ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └─┘ ┴ └─┘
doc └─┘ └─┘ └─┘
862
863 theorem eq_preimage_subtype_val_iff {p : α → Prop} {s : set (subtype p)} {t : set α} :
id ┴ └─┘ └─────┘ ┴ └─┘ ┴
src └─┘ └─────┘ └─┘
typ ┴ └─┘ └─────┘ ┴ └─┘ ┴
864 s = subtype.val ⁻¹' t ↔ (∀x (h : p x), (⟨x, h⟩ : subtype p) ∈ s ↔ x ∈ t) :=
id ┴ ┴ └─────────┘ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └─────────┘ └─┘ ┴ └─────┘ ┴ ┴ ┴
typ ┴ ┴ └─────────┘ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └─┘
865 ⟨assume s_eq x h, by rw [s_eq]; simp,
id └──┘ ┴ ┴ └──┘
src └──┘ ┴ └──┘
typ └──┘ ┴ ┴ └──┘└──┘┴ └──┘
doc └──┘ ┴ └──┘
txt └──┘ ┴ └──┘
par └──┘ ┴ └──┘
pid └┘ ┴
st └───────┘┴└────┘
866 assume h, ext $ assume ⟨x, hx⟩, by simp [h]⟩
id ┴ └─┘ ┴ ┴
src └─┘ └────┘ ┴
typ ┴ └─┘ ┴ └────┘┴┴
doc └────┘ ┴
txt └────┘ ┴
par └────┘ ┴
pid ┴┴ ┴
st └───────┘
867
868 lemma if_preimage (s : set α) [decidable_pred s] (f g : α → β) (t : set β) :
id └─┘ ┴ └────────────┘ ┴ ┴ ┴ └─┘ ┴
src └─┘ └────────────┘ └─┘
typ └─┘ ┴ └────────────┘ ┴ ┴ ┴ └─┘ ┴
869 (λa, if a ∈ s then f a else g a)⁻¹' t = (s ∩ f ⁻¹' t) ∪ (-s ∩ g ⁻¹' t) :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴
doc └─┘ └─┘ └─┘
870 begin
st └─────
871 ext,
src └─┘
typ └─┘
doc └─┘
txt └─┘
par └─┘
st ────┘└─
872 simp only [mem_inter_eq, mem_union_eq, mem_preimage],
id └──────────┘ └──────────┘ └──────────┘
src └─────────┘└──────────┘└┘└──────────┘└┘└──────────┘┴
typ └─────────┘└──────────┘└┘└──────────┘└┘└──────────┘┴
doc └─────────┘ └┘ └┘ ┴
txt └─────────┘ └┘ └┘ ┴
par └─────────┘ └┘ └┘ ┴
pid ┴└──┘└┘ └┘ └┘ ┴
st ─────────────────────────────────────────────────────┘└─
873 split_ifs;
src └───────┘
typ └───────┘
doc └───────┘
txt └───────┘
par └───────┘
st ─────────────
874 simp [mem_def, h]
id └─────┘ ┴
src └────┘└─────┘└┘ └┘
typ └────┘└─────┘└┘┴└┘
doc └────┘ └┘ └┘
txt └────┘ └┘ └┘
par └────┘ └┘ └┘
pid ┴┴ └┘ ┴┴
st ───────────────────┘
875 end
st └─┘
876
877 end preimage
878
879 /-! ### Image of a set under a function -/
880
881 section image
882
883 infix ` '' `:80 := image
id └───┘
src └───┘
typ └───┘
884
885 /-- Two functions `f₁ f₂ : α → β` are equal on `s`
886 if `f₁ x = f₂ x` for all `x ∈ a`. -/
887 @[reducible] def eq_on (f1 f2 : α → β) (a : set α) : Prop :=
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
doc └───────┘
888 ∀ x ∈ a, f1 x = f2 x
id ┴ ┴ └┘ ┴ ┴ └┘ ┴
src ┴
typ ┴ ┴ └┘ ┴ ┴ └┘ ┴
889
890 -- TODO(Jeremy): use bounded exists in image
891
892 theorem mem_image_iff_bex {f : α → β} {s : set α} {y : β} :
id ┴ ┴ └─┘ ┴ ┴
src └─┘
typ ┴ ┴ └─┘ ┴ ┴
893 y ∈ f '' s ↔ ∃ x (_ : x ∈ s), f x = y := bex_def.symm
id ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘└───┘
src ┴ └┘ ┴ ┴ ┴ ┴ ┴ └─────┘└───┘
typ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘└───┘
894
895 theorem mem_image_eq (f : α → β) (s : set α) (y: β) : y ∈ f '' s = ∃ x, x ∈ s ∧ f x = y := rfl
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src └─┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
896
897 @[simp] theorem mem_image (f : α → β) (s : set α) (y : β) : y ∈ f '' s ↔ ∃ x, x ∈ s ∧ f x = y := iff.rfl
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘
898
899 theorem mem_image_of_mem (f : α → β) {x : α} {a : set α} (h : x ∈ a) : f x ∈ f '' a :=
id ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
src └─┘ ┴ ┴ └┘
typ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
900 ⟨_, h, rfl⟩
id ┴ └─┘
src └─┘
typ ┴ └─┘
901
902 theorem mem_image_of_injective {f : α → β} {a : α} {s : set α} (hf : injective f) :
id ┴ ┴ ┴ └─┘ ┴ └───────┘ ┴
src └─┘ └───────┘
typ ┴ ┴ ┴ └─┘ ┴ └───────┘ ┴
903 f a ∈ f '' s ↔ a ∈ s :=
id ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ ┴ ┴
typ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
904 iff.intro
id └───────┘
src └───────┘
typ └───────┘
905 (assume ⟨b, hb, eq⟩, (hf eq) ▸ hb)
id ┴ └┘ └┘ └┘ ┴
src └┘ ┴
typ ┴ └┘ └┘ └┘ ┴
906 (assume h, mem_image_of_mem _ h)
id ┴ └──────────────┘ ┴
src └──────────────┘
typ ┴ └──────────────┘ ┴
907
908 theorem ball_image_of_ball {f : α → β} {s : set α} {p : β → Prop}
id ┴ ┴ └─┘ ┴ ┴
src └─┘
typ ┴ ┴ └─┘ ┴ ┴
909 (h : ∀ x ∈ s, p (f x)) : ∀ y ∈ f '' s, p y :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src └┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
910 by finish [mem_image_eq]
id └──────────┘
src └──────┘└──────────┘└─
typ └──────┘└──────────┘└─
doc └──────┘ └─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └──────────────────────
911
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
912 @[simp] theorem ball_image_iff {f : α → β} {s : set α} {p : β → Prop} :
id ┴ ┴ └─┘ ┴ ┴
src └─┘
typ ┴ ┴ └─┘ ┴ ┴
doc └──┘
913 (∀ y ∈ f '' s, p y) ↔ (∀ x ∈ s, p (f x)) :=
id ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └┘ ┴
typ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
914 iff.intro
id └───────┘
src └───────┘
typ └───────┘
915 (assume h a ha, h _ $ mem_image_of_mem _ ha)
id ┴ ┴ └┘ ┴ └──────────────┘ └┘
src └──────────────┘
typ ┴ ┴ └┘ ┴ └──────────────┘ └┘
916 (assume h b ⟨a, ha, eq⟩, eq ▸ h a ha)
id ┴ ┴ ┴┴ └┘ └┘ ┴ ┴
src └┘ ┴
typ ┴ ┴ ┴┴ └┘ └┘ ┴ ┴
917
918 theorem mono_image {f : α → β} {s t : set α} (h : s ⊆ t) : f '' s ⊆ f '' t :=
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
src └─┘ ┴ └┘ ┴ └┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
919 assume x ⟨y, hy, y_eq⟩, y_eq ▸ mem_image_of_mem _ $ h hy
id ┴ ┴ └┘ └──┘ ┴ └──────────────┘ ┴
src ┴ └──────────────┘
typ ┴ ┴ └┘ └──┘ ┴ └──────────────┘ ┴
920
921 theorem mem_image_elim {f : α → β} {s : set α} {C : β → Prop} (h : ∀ (x : α), x ∈ s → C (f x)) :
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
922 ∀{y : β}, y ∈ f '' s → C y
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ └┘
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
923 | ._ ⟨a, a_in, rfl⟩ := h a a_in
id ┴ └──┘ └─┘ ┴
src └─┘
typ ┴ └──┘ └─┘ ┴
924
925 theorem mem_image_elim_on {f : α → β} {s : set α} {C : β → Prop} {y : β} (h_y : y ∈ f '' s)
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
src └─┘ ┴ └┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
926 (h : ∀ (x : α), x ∈ s → C (f x)) : C y :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
927 mem_image_elim h h_y
id └────────────┘ ┴ └─┘
src └────────────┘
typ └────────────┘ ┴ └─┘
928
929 @[congr] lemma image_congr {f g : α → β} {s : set α}
id ┴ ┴ └─┘ ┴
src └───┘ └─┘
typ ┴ ┴ └─┘ ┴
doc └───┘
930 (h : ∀a∈s, f a = g a) : f '' s = g '' s :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
931 by safe [ext_iff, iff_def]
id └─────┘ └─────┘
src └────┘└─────┘└┘└─────┘└─
typ └────┘└─────┘└┘└─────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid └┘ └┘ ┴└
st └────────────────────────
932
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
933 /-- A common special case of `image_congr` -/
934 lemma image_congr' {f g : α → β} {s : set α} (h : ∀ (x : α), f x = g x) : f '' s = g '' s :=
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
src └─┘ ┴ └┘ ┴ └┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
935 image_congr (λx _, h x)
id └─────────┘ ┴ ┴ ┴ ┴
src └─────────┘
typ └─────────┘ ┴ ┴ ┴ ┴
936
937 theorem image_eq_image_of_eq_on {f₁ f₂ : α → β} {s : set α} (heq : eq_on f₁ f₂ s) :
id ┴ ┴ └─┘ ┴ └───┘ └┘ └┘ ┴
src └─┘ └───┘
typ ┴ ┴ └─┘ ┴ └───┘ └┘ └┘ ┴
doc └───┘
938 f₁ '' s = f₂ '' s :=
id └┘ └┘ ┴ ┴ └┘ └┘ ┴
src └┘ ┴ └┘
typ └┘ └┘ ┴ ┴ └┘ └┘ ┴
939 image_congr heq
id └─────────┘ └─┘
src └─────────┘ └─┘
typ └─────────┘ └─┘
940
941 theorem image_comp (f : β → γ) (g : α → β) (a : set α) : (f ∘ g) '' a = f '' (g '' a) :=
id ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴
src └─┘ ┴ └┘ ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴
942 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
943 (ball_image_of_ball $ assume a ha, mem_image_of_mem _ $ mem_image_of_mem _ ha)
id └────────────────┘ ┴ └┘ └──────────────┘ └──────────────┘ └┘
src └────────────────┘ └──────────────┘ └──────────────┘
typ └────────────────┘ ┴ └┘ └──────────────┘ └──────────────┘ └┘
944 (ball_image_of_ball $ ball_image_of_ball $ assume a ha, mem_image_of_mem _ ha)
id └────────────────┘ └────────────────┘ ┴ └┘ └──────────────┘ └┘
src └────────────────┘ └────────────────┘ └──────────────┘
typ └────────────────┘ └────────────────┘ ┴ └┘ └──────────────┘ └┘
945 /- Proof is removed as it uses generated names
946 TODO(Jeremy): make automatic,
947 begin
948 safe [ext_iff, iff_def, mem_image, (∘)],
949 have h' := h_2 (g a_2),
950 finish
951 end -/
952
953 /-- A variant of `image_comp`, useful for rewriting -/
954 lemma image_image (g : β → γ) (f : α → β) (s : set α) : g '' (f '' s) = (λ x, g (f x)) '' s :=
id ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
src └─┘ └┘ └┘ ┴ └┘
typ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
955 (image_comp g f s).symm
id └────────┘ ┴ ┴ ┴ └──┘
src └────────┘ └──┘
typ └────────┘ ┴ ┴ ┴ └──┘
956
957
958 theorem image_subset {a b : set α} (f : α → β) (h : a ⊆ b) : f '' a ⊆ f '' b :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
src └─┘ ┴ └┘ ┴ └┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
959 by finish [subset_def, mem_image_eq]
id └────────┘ └──────────┘
src └──────┘└────────┘└┘└──────────┘└─
typ └──────┘└────────┘└┘└──────────┘└─
doc └──────┘ └┘ └─
txt └──────┘ └┘ └─
par └──────┘ └┘ └─
pid └┘ └┘ ┴└
st └──────────────────────────────────
960
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
961 theorem image_union (f : α → β) (s t : set α) :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
962 f '' (s ∪ t) = f '' s ∪ f '' t :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
src └┘ ┴ ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴
963 by finish [ext_iff, iff_def, mem_image_eq]
id └─────┘ └─────┘ └──────────┘
src └──────┘└─────┘└┘└─────┘└┘└──────────┘└─
typ └──────┘└─────┘└┘└─────┘└┘└──────────┘└─
doc └──────┘ └┘ └┘ └─
txt └──────┘ └┘ └┘ └─
par └──────┘ └┘ └┘ └─
pid └┘ └┘ └┘ ┴└
st └────────────────────────────────────────
964
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
965 @[simp] theorem image_empty (f : α → β) : f '' ∅ = ∅ := ext $ by simp
id ┴ ┴ ┴ └┘ ┴ ┴ ┴ └─┘
src └┘ ┴ ┴ ┴ └─┘ └────
typ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └─┘ └────
doc └──┘ └────
txt └────
par └────
pid └
st └─────
966
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
967 theorem image_inter_on {f : α → β} {s t : set α} (h : ∀x∈t, ∀y∈s, f x = f y → x = y) :
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
968 f '' s ∩ f '' t = f '' (s ∩ t) :=
id ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src └┘ ┴ └┘ ┴ └┘ ┴
typ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
969 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
970 (assume b ⟨⟨a₁, ha₁, h₁⟩, ⟨a₂, ha₂, h₂⟩⟩,
id ┴ ┴ └┘ └─┘ └┘ └┘ └─┘
typ ┴ ┴ └┘ └─┘ └┘ └┘ └─┘
971 have a₂ = a₁, from h _ ha₂ _ ha₁ (by simp *),
id ┴ ┴
src ┴ └────┘
typ ┴ ┴ └────┘
doc └────┘
txt └────┘
par └────┘
pid ┴┴
st └─────┘
972 ⟨a₁, ⟨ha₁, this ▸ ha₂⟩, h₁⟩)
id └──┘ ┴
src ┴
typ └──┘ ┴
973 (subset_inter (mono_image $ inter_subset_left _ _) (mono_image $ inter_subset_right _ _))
id └──────────┘ └────────┘ └───────────────┘ └────────┘ └────────────────┘
src └──────────┘ └────────┘ └───────────────┘ └────────┘ └────────────────┘
typ └──────────┘ └────────┘ └───────────────┘ └────────┘ └────────────────┘
974
975 theorem image_inter {f : α → β} {s t : set α} (H : injective f) :
id ┴ ┴ └─┘ ┴ └───────┘ ┴
src └─┘ └───────┘
typ ┴ ┴ └─┘ ┴ └───────┘ ┴
976 f '' s ∩ f '' t = f '' (s ∩ t) :=
id ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src └┘ ┴ └┘ ┴ └┘ ┴
typ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
977 image_inter_on (assume x _ y _ h, H h)
id └────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └────────────┘
typ └────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
978
979 theorem image_univ_of_surjective {ι : Type*} {f : ι → β} (H : surjective f) : f '' univ = univ :=
id ┴ ┴ └────────┘ ┴ ┴ └┘ └──┘ ┴ └──┘
src └────────┘ └┘ └──┘ ┴ └──┘
typ ┴ ┴ └────────┘ ┴ ┴ └┘ └──┘ ┴ └──┘
980 eq_univ_of_forall $ by simp [image]; exact H
id └───────────────┘ └───┘ ┴
src └───────────────┘ └────┘└───┘┴ └────┘ └
typ └───────────────┘ └────┘└───┘┴ └────┘┴└
doc └────┘ ┴ └────┘ └
txt └────┘ ┴ └────┘ └
par └────┘ ┴ └────┘ └
pid ┴┴ ┴ ┴ └
st └──────────────────────
981
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
982 @[simp] theorem image_singleton {f : α → β} {a : α} : f '' {a} = {f a} :=
id ┴ ┴ ┴ ┴ └┘ ┴┴ ┴ ┴┴ ┴
src └┘ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ └┘ ┴┴ ┴ ┴┴ ┴
doc └──┘
983 ext $ λ x, by simp [image]; rw eq_comm
id └─┘ ┴ └───┘ └─────┘
src └─┘ └────┘└───┘┴ └─┘└─────┘└
typ └─┘ ┴ └────┘└───┘┴ └─┘└─────┘└
doc └────┘ ┴ └─┘ └
txt └────┘ ┴ └─┘ └
par └────┘ ┴ └─┘ └
pid ┴┴ ┴ ┴ └
st └────────────────┘└─────┘└
984
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
985 theorem nonempty.image_const {s : set α} (hs : s.nonempty) (a : β) : (λ _, a) '' s = {a} :=
id └─┘ ┴ ┴└───────┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴┴
src └─┘ └───────┘ └┘ ┴ ┴
typ └─┘ ┴ ┴└───────┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴┴
doc └───────┘
986 ext $ λ x, ⟨λ ⟨y, _, h⟩, h ▸ mem_singleton _,
id └─┘ ┴ ┴ ┴ ┴ └───────────┘
src └─┘ ┴ └───────────┘
typ └─┘ ┴ ┴ ┴ ┴ └───────────┘
987 λ h, (eq_of_mem_singleton h).symm ▸ hs.imp (λ y hy, ⟨hy, rfl⟩)⟩
id ┴ └─────────────────┘ ┴ └──┘ ┴ └┘└──┘ ┴ └┘ └┘ └─┘
src └─────────────────┘ └──┘ ┴ └──┘ └─┘
typ ┴ └─────────────────┘ ┴ └──┘ ┴ └┘└──┘ ┴ └┘ └┘ └─┘
988
989 @[simp] lemma image_eq_empty {α β} {f : α → β} {s : set α} : f '' s = ∅ ↔ s = ∅ :=
id ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ └┘ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
990 by simp only [eq_empty_iff_forall_not_mem]; exact
id └─────────────────────────┘
src └─────────┘└─────────────────────────┘┴ └────┘
typ └─────────┘└─────────────────────────┘┴ └────┘
doc └─────────┘ ┴ └────┘
txt └─────────┘ ┴ └────┘
par └─────────┘ ┴ └────┘
pid ┴└──┘└┘ ┴ ┴
st └───────────────────────────────────────────────
991 ⟨λ H a ha, H _ ⟨_, ha, rfl⟩, λ H b ⟨_, ha, _⟩, H _ ha⟩
id └─┘ └┘
src └───────┘ └─┘ └─┘ └┘└─┘└─┘ └───────┘ └────┘ └─┘ └─
typ └───────┘ └─┘ └─┘ └┘└─┘└─┘ └───────┘└┘└────┘ └─┘ └─
doc └───────┘ └─┘ └─┘ └┘ └─┘ └───────┘ └────┘ └─┘ └─
txt └───────┘ └─┘ └─┘ └┘ └─┘ └───────┘ └────┘ └─┘ └─
par └───────┘ └─┘ └─┘ └┘ └─┘ └───────┘ └────┘ └─┘ └─
pid └───────┘ └─┘ └─┘ └┘ └─┘ └───────┘ └────┘ └─┘ ┴└
st ───────────────────────────────────────────────────────
992
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
993 lemma inter_singleton_nonempty {s : set α} {a : α} : (s ∩ {a}).nonempty ↔ a ∈ s :=
id └─┘ ┴ ┴ ┴ ┴ ┴┴ └──────┘ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ └──────┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴┴ └──────┘ ┴ ┴ ┴ ┴
doc └──────┘
994 by finish [set.nonempty]
id └──────────┘
src └──────┘└──────────┘└─
typ └──────┘└──────────┘└─
doc └──────┘└──────────┘└─
txt └──────┘ └─
par └──────┘ └─
pid └┘ ┴└
st └──────────────────────
995
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
996 theorem fix_set_compl (t : set α) : compl t = - t := rfl
id └─┘ ┴ └───┘ ┴ ┴ ┴ ┴ └─┘
src └─┘ └───┘ ┴ ┴ └─┘
typ └─┘ ┴ └───┘ ┴ ┴ ┴ ┴ └─┘
997
998 -- TODO(Jeremy): there is an issue with - t unfolding to compl t
999 theorem mem_compl_image (t : set α) (S : set (set α)) :
id └─┘ ┴ └─┘ └─┘ ┴
src └─┘ └─┘ └─┘
typ └─┘ ┴ └─┘ └─┘ ┴
1000 t ∈ compl '' S ↔ -t ∈ S :=
id ┴ ┴ └───┘ └┘ ┴ ┴ ┴┴ ┴ ┴
src ┴ └───┘ └┘ ┴ ┴ ┴
typ ┴ ┴ └───┘ └┘ ┴ ┴ ┴┴ ┴ ┴
1001 begin
st └─────
1002 suffices : ∀ x, -x = t ↔ -t = x, {simp [fix_set_compl, this]},
id ┴ ┴ ┴ └───────────┘ └──┘
src └─────────┘ └┘ ┴┴ ┴┴┴ ┴ ┴ ┴ ┴ └────┘└───────────┘└┘ ┴
typ └─────────┘ └┘ ┴┴ ┴┴┴ ┴ ┴ ┴┴ ┴ └────┘└───────────┘└┘└──┘┴
doc └─────────┘ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ └┘ ┴
txt └─────────┘ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ └┘ ┴
par └─────────┘ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └────┘ └┘ ┴
pid └───────┘└┘ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ └┘ ┴
st ────────────────────────────────┘└───────────────────────────┘└┘└
1003 intro x, split; { intro e, subst e, simp }
id ┴
src └─────┘ └───┘ └─────┘ └────┘ └───┘
typ └─────┘ └───┘ └─────┘ └────┘┴ └───┘
doc └─────┘ └───┘ └─────┘ └────┘ └───┘
txt └─────┘ └───┘ └─────┘ └────┘ └───┘
par └─────┘ └───┘ └─────┘ └────┘ └───┘
pid └┘ └┘ ┴ ┴
st ────────┘└───────┘└───────┘└───────┘└─────┘└─
1004 end
st ──┘
1005
1006 @[simp] theorem image_id (s : set α) : id '' s = s := ext $ by simp
id └─┘ ┴ └┘ └┘ ┴ ┴ ┴ └─┘
src └─┘ └┘ └┘ ┴ └─┘ └────
typ └─┘ ┴ └┘ └┘ ┴ ┴ ┴ └─┘ └────
doc └──┘ └────
txt └────
par └────
pid └
st └─────
1007
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1008 /-- A variant of `image_id` -/
1009 @[simp] lemma image_id' (s : set α) : (λx, x) '' s = s := image_id s
id └─┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └──────┘ ┴
src └─┘ └┘ ┴ └──────┘
typ └─┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └──────┘ ┴
doc └──┘
1010
1011 theorem compl_compl_image (S : set (set α)) :
id └─┘ └─┘ ┴
src └─┘ └─┘
typ └─┘ └─┘ ┴
1012 compl '' (compl '' S) = S :=
id └───┘ └┘ └───┘ └┘ ┴ ┴ ┴
src └───┘ └┘ └───┘ └┘ ┴
typ └───┘ └┘ └───┘ └┘ ┴ ┴ ┴
1013 by rw [← image_comp, compl_comp_compl, image_id]
id └────────┘ └──────────────┘ └──────┘
src └────┘└────────┘└┘└──────────────┘└┘└──────┘└─
typ └────┘└────────┘└┘└──────────────┘└┘└──────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid └──┘ └┘ └┘ ┴└
st └───────────────┘└────────────────┘└────────┘┴└
1014
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1015 theorem image_insert_eq {f : α → β} {a : α} {s : set α} :
id ┴ ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ ┴ └─┘ ┴
1016 f '' (insert a s) = insert (f a) (f '' s) :=
id ┴ └┘ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ └┘ ┴
src └┘ └────┘ ┴ └────┘ └┘
typ ┴ └┘ └────┘ ┴ ┴ ┴ └────┘ ┴ ┴ ┴ └┘ ┴
1017 ext $ by simp [and_or_distrib_left, exists_or_distrib, eq_comm, or_comm, and_comm]
id └─┘ └─────────────────┘ └───────────────┘ └─────┘ └─────┘ └──────┘
src └─┘ └────┘└─────────────────┘└┘└───────────────┘└┘└─────┘└┘└─────┘└┘└──────┘└─
typ └─┘ └────┘└─────────────────┘└┘└───────────────┘└┘└─────┘└┘└─────┘└┘└──────┘└─
doc └────┘ └┘ └┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └┘ └┘ └─
par └────┘ └┘ └┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ └┘ └┘ ┴└
st └──────────────────────────────────────────────────────────────────────────
1018
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1019 theorem image_pair (f : α → β) (a b : α) : f '' {a, b} = {f a, f b} :=
id ┴ ┴ ┴ ┴ └┘ ┴┴┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴
src └┘ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ └┘ ┴┴┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴
1020 by simp only [insert_of_has_insert, image_insert_eq, image_singleton]
id └──────────────────┘ └─────────────┘ └─────────────┘
src └─────────┘└──────────────────┘└┘└─────────────┘└┘└─────────────┘└─
typ └─────────┘└──────────────────┘└┘└─────────────┘└┘└─────────────┘└─
doc └─────────┘ └┘ └┘ └─
txt └─────────┘ └┘ └┘ └─
par └─────────┘ └┘ └┘ └─
pid ┴└──┘└┘ └┘ └┘ ┴└
st └───────────────────────────────────────────────────────────────────
1021
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1022 theorem image_subset_preimage_of_inverse {f : α → β} {g : β → α}
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1023 (I : left_inverse g f) (s : set α) : f '' s ⊆ g ⁻¹' s :=
id └──────────┘ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ └─┘ ┴
src └──────────┘ └─┘ └┘ ┴ └─┘
typ └──────────┘ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ └─┘ ┴
doc └─┘
1024 λ b ⟨a, h, e⟩, e ▸ ((I a).symm ▸ h : g (f a) ∈ s)
id ┴ ┴┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴
src ┴ └──┘ ┴ ┴
typ ┴ ┴┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴
1025
1026 theorem preimage_subset_image_of_inverse {f : α → β} {g : β → α}
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1027 (I : left_inverse g f) (s : set β) : f ⁻¹' s ⊆ g '' s :=
id └──────────┘ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴
src └──────────┘ └─┘ └─┘ ┴ └┘
typ └──────────┘ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴
doc └─┘
1028 λ b h, ⟨f b, h, I b⟩
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1029
1030 theorem image_eq_preimage_of_inverse {f : α → β} {g : β → α}
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1031 (h₁ : left_inverse g f) (h₂ : right_inverse g f) :
id └──────────┘ ┴ ┴ └───────────┘ ┴ ┴
src └──────────┘ └───────────┘
typ └──────────┘ ┴ ┴ └───────────┘ ┴ ┴
1032 image f = preimage g :=
id └───┘ ┴ ┴ └──────┘ ┴
src └───┘ ┴ └──────┘
typ └───┘ ┴ ┴ └──────┘ ┴
doc └──────┘
1033 funext $ λ s, subset.antisymm
id └────┘ ┴ └─────────────┘
src └────┘ └─────────────┘
typ └────┘ ┴ └─────────────┘
1034 (image_subset_preimage_of_inverse h₁ s)
id └──────────────────────────────┘ └┘ ┴
src └──────────────────────────────┘
typ └──────────────────────────────┘ └┘ ┴
1035 (preimage_subset_image_of_inverse h₂ s)
id └──────────────────────────────┘ └┘ ┴
src └──────────────────────────────┘
typ └──────────────────────────────┘ └┘ ┴
1036
1037 theorem mem_image_iff_of_inverse {f : α → β} {g : β → α} {b : β} {s : set α}
id ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
1038 (h₁ : left_inverse g f) (h₂ : right_inverse g f) :
id └──────────┘ ┴ ┴ └───────────┘ ┴ ┴
src └──────────┘ └───────────┘
typ └──────────┘ ┴ ┴ └───────────┘ ┴ ┴
1039 b ∈ f '' s ↔ g b ∈ s :=
id ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ ┴ ┴
typ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴
1040 by rw image_eq_preimage_of_inverse h₁ h₂; refl
id └──────────────────────────┘ └┘ └┘
src └─┘└──────────────────────────┘┴ ┴ └────
typ └─┘└──────────────────────────┘┴└┘┴└┘ └────
doc └─┘ ┴ ┴ └────
txt └─┘ ┴ ┴ └────
par └─┘ ┴ ┴ └────
pid ┴ ┴ ┴ └
st └────────────────────────────────────────────
1041
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1042 theorem image_compl_subset {f : α → β} {s : set α} (H : injective f) : f '' -s ⊆ -(f '' s) :=
id ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └┘ ┴┴ ┴ ┴ ┴ └┘ ┴
src └─┘ └───────┘ └┘ ┴ ┴ ┴ └┘
typ ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └┘ ┴┴ ┴ ┴ ┴ └┘ ┴
1043 subset_compl_iff_disjoint.2 $ by simp [image_inter H]
id └───────────────────────┘┴ └─────────┘ ┴
src └───────────────────────┘┴ └────┘└─────────┘┴ └─
typ └───────────────────────┘┴ └────┘└─────────┘┴┴└─
doc └────┘ ┴ └─
txt └────┘ ┴ └─
par └────┘ ┴ └─
pid ┴┴ ┴ ┴└
st └─────────────────────
1044
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1045 theorem subset_image_compl {f : α → β} {s : set α} (H : surjective f) : -(f '' s) ⊆ f '' -s :=
id ┴ ┴ └─┘ ┴ └────────┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴┴
src └─┘ └────────┘ ┴ └┘ ┴ └┘ ┴
typ ┴ ┴ └─┘ ┴ └────────┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴┴
1046 compl_subset_iff_union.2 $
id └────────────────────┘┴
src └────────────────────┘┴
typ └────────────────────┘┴
1047 by rw ← image_union; simp [image_univ_of_surjective H]
id └─────────┘ └──────────────────────┘ ┴
src └───┘└─────────┘ └────┘└──────────────────────┘┴ └─
typ └───┘└─────────┘ └────┘└──────────────────────┘┴┴└─
doc └───┘ └────┘ ┴ └─
txt └───┘ └────┘ ┴ └─
par └───┘ └────┘ ┴ └─
pid └─┘ ┴┴ ┴ ┴└
st └────────────────────────────────────────────────────
1048
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1049 theorem image_compl_eq {f : α → β} {s : set α} (H : bijective f) : f '' -s = -(f '' s) :=
id ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └┘ ┴┴ ┴ ┴ ┴ └┘ ┴
src └─┘ └───────┘ └┘ ┴ ┴ ┴ └┘
typ ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └┘ ┴┴ ┴ ┴ ┴ └┘ ┴
1050 subset.antisymm (image_compl_subset H.1) (subset_image_compl H.2)
id └─────────────┘ └────────────────┘ ┴┴ └────────────────┘ ┴┴
src └─────────────┘ └────────────────┘ ┴ └────────────────┘ ┴
typ └─────────────┘ └────────────────┘ ┴┴ └────────────────┘ ┴┴
1051
1052 lemma nonempty.image (f : α → β) {s : set α} : s.nonempty → (f '' s).nonempty
id ┴ ┴ └─┘ ┴ ┴└───────┘ ┴ ┴ └┘ ┴ └──────┘
src └─┘ └───────┘ └┘ └──────┘
typ ┴ ┴ └─┘ ┴ ┴└───────┘ ┴ ┴ └┘ ┴ └──────┘
doc └───────┘ └──────┘
1053 | ⟨x, hx⟩ := ⟨f x, mem_image_of_mem f hx⟩
id ┴ └┘ ┴ └──────────────┘ ┴
src └──────────────┘
typ ┴ └┘ ┴ └──────────────┘ ┴
1054
1055 lemma nonempty.of_image {f : α → β} {s : set α} : (f '' s).nonempty → s.nonempty
id ┴ ┴ └─┘ ┴ ┴ └┘ ┴ └──────┘ ┴ ┴└───────┘
src └─┘ └┘ └──────┘ └───────┘
typ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ └──────┘ ┴ ┴└───────┘
doc └──────┘ └───────┘
1056 | ⟨y, x, hx, _⟩ := ⟨x, hx⟩
id ┴ └┘
typ ┴ └┘
1057
1058 @[simp] lemma nonempty_image_iff {f : α → β} {s : set α} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
doc └──┘
1059 (f '' s).nonempty ↔ s.nonempty :=
id ┴ └┘ ┴ └──────┘ ┴ ┴└───────┘
src └┘ └──────┘ ┴ └───────┘
typ ┴ └┘ ┴ └──────┘ ┴ ┴└───────┘
doc └──────┘ └───────┘
1060 ⟨nonempty.of_image, λ h, h.image f⟩
id └───────────────┘ ┴ ┴└────┘ ┴
src └───────────────┘ └────┘
typ └───────────────┘ ┴ ┴└────┘ ┴
1061
1062 /-- image and preimage are a Galois connection -/
1063 theorem image_subset_iff {s : set α} {t : set β} {f : α → β} :
id └─┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ ┴ ┴
1064 f '' s ⊆ t ↔ s ⊆ f ⁻¹' t :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src └┘ ┴ ┴ ┴ └─┘
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc └─┘
1065 ball_image_iff
id └────────────┘
src └────────────┘
typ └────────────┘
1066
1067 theorem image_preimage_subset (f : α → β) (s : set β) :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1068 f '' (f ⁻¹' s) ⊆ s :=
id ┴ └┘ ┴ └─┘ ┴ ┴ ┴
src └┘ └─┘ ┴
typ ┴ └┘ ┴ └─┘ ┴ ┴ ┴
doc └─┘
1069 image_subset_iff.2 (subset.refl _)
id └──────────────┘┴ └─────────┘
src └──────────────┘┴ └─────────┘
typ └──────────────┘┴ └─────────┘
doc └──────────────┘
1070
1071 theorem subset_preimage_image (f : α → β) (s : set α) :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1072 s ⊆ f ⁻¹' (f '' s) :=
id ┴ ┴ ┴ └─┘ ┴ └┘ ┴
src ┴ └─┘ └┘
typ ┴ ┴ ┴ └─┘ ┴ └┘ ┴
doc └─┘
1073 λ x, mem_image_of_mem f
id ┴ └──────────────┘ ┴
src └──────────────┘
typ ┴ └──────────────┘ ┴
1074
1075 theorem preimage_image_eq {f : α → β} (s : set α) (h : injective f) : f ⁻¹' (f '' s) = s :=
id ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
src └─┘ └───────┘ └─┘ └┘ ┴
typ ┴ ┴ └─┘ ┴ └───────┘ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
doc └─┘
1076 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
1077 (λ x ⟨y, hy, e⟩, h e ▸ hy)
id ┴ ┴ └┘ ┴ ┴ ┴
src ┴
typ ┴ ┴ └┘ ┴ ┴ ┴
1078 (subset_preimage_image f s)
id └───────────────────┘ ┴ ┴
src └───────────────────┘
typ └───────────────────┘ ┴ ┴
1079
1080 theorem image_preimage_eq {f : α → β} {s : set β} (h : surjective f) : f '' (f ⁻¹' s) = s :=
id ┴ ┴ └─┘ ┴ └────────┘ ┴ ┴ └┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └────────┘ └┘ └─┘ ┴
typ ┴ ┴ └─┘ ┴ └────────┘ ┴ ┴ └┘ ┴ └─┘ ┴ ┴ ┴
doc └─┘
1081 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
1082 (image_preimage_subset f s)
id └───────────────────┘ ┴ ┴
src └───────────────────┘
typ └───────────────────┘ ┴ ┴
1083 (λ x hx, let ⟨y, e⟩ := h x in ⟨y, (e.symm ▸ hx : f y ∈ s), e⟩)
id ┴ └┘ └─┘ ┴ ┴ ┴ ┴ └───┘ ┴ └┘ ┴ ┴ ┴
src └───┘ ┴ ┴
typ ┴ └┘ └─┘ ┴ ┴ ┴ ┴ └───┘ ┴ └┘ ┴ ┴ ┴
1084
1085 lemma preimage_eq_preimage {f : β → α} (hf : surjective f) : f ⁻¹' s = preimage f t ↔ s = t :=
id ┴ ┴ └────────┘ ┴ ┴ └─┘ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴
src └────────┘ └─┘ ┴ └──────┘ ┴ ┴
typ ┴ ┴ └────────┘ ┴ ┴ └─┘ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └─┘ └──────┘
1086 iff.intro
id └───────┘
src └───────┘
typ └───────┘
1087 (assume eq, by rw [← @image_preimage_eq β α f s hf, ← @image_preimage_eq β α f t hf, eq])
id └┘ └───────────────┘ ┴ ┴ ┴ ┴ └┘ └───────────────┘ ┴ ┴ ┴ ┴ └┘ └┘
src └┘ └────┘ └───────────────┘┴ ┴ ┴ ┴ ┴ └──┘ └───────────────┘┴ ┴ ┴ ┴ ┴ └┘└┘┴
typ └┘ └────┘ └───────────────┘┴┴┴┴┴┴┴┴┴└┘└──┘ └───────────────┘┴┴┴┴┴┴┴┴┴└┘└┘└┘┴
doc └────┘ ┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴
txt └────┘ ┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴
par └────┘ ┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴
pid └──┘ ┴ ┴ ┴ ┴ ┴ └──┘ ┴ ┴ ┴ ┴ ┴ └┘ ┴
st └──────────────────────────────────┘└───────────────────────────────┘└──┘┴
1088 (assume eq, eq ▸ rfl)
id └┘ └┘ ┴ └─┘
src └┘ └┘ ┴ └─┘
typ └┘ └┘ ┴ └─┘
1089
1090 lemma surjective_preimage {f : β → α} (hf : surjective f) : injective (preimage f) :=
id ┴ ┴ └────────┘ ┴ └───────┘ └──────┘ ┴
src └────────┘ └───────┘ └──────┘
typ ┴ ┴ └────────┘ ┴ └───────┘ └──────┘ ┴
doc └──────┘
1091 assume s t, (preimage_eq_preimage hf).1
id ┴ ┴ └──────────────────┘ └┘ ┴
src └──────────────────┘ ┴
typ ┴ ┴ └──────────────────┘ └┘ ┴
1092
1093 theorem compl_image : image (@compl α) = preimage compl :=
id └───┘ └───┘ ┴ ┴ └──────┘ └───┘
src └───┘ └───┘ ┴ └──────┘ └───┘
typ └───┘ └───┘ ┴ ┴ └──────┘ └───┘
doc └──────┘
1094 image_eq_preimage_of_inverse compl_compl compl_compl
id └──────────────────────────┘ └─────────┘ └─────────┘
src └──────────────────────────┘ └─────────┘ └─────────┘
typ └──────────────────────────┘ └─────────┘ └─────────┘
1095
1096 theorem compl_image_set_of {α : Type u} {p : set α → Prop} :
id └─┘ ┴
src └─┘
typ └─┘ ┴
1097 compl '' {x | p x} = {x | p (- x)} :=
id └───┘ └┘ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src └───┘ └┘ ┴ ┴ ┴ ┴
typ └───┘ └┘ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
1098 congr_fun compl_image p
id └───────┘ └─────────┘ ┴
src └───────┘ └─────────┘
typ └───────┘ └─────────┘ ┴
1099
1100 theorem inter_preimage_subset (s : set α) (t : set β) (f : α → β) :
id └─┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ ┴ ┴
1101 s ∩ f ⁻¹' t ⊆ f ⁻¹' (f '' s ∩ t) :=
id ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
src ┴ └─┘ ┴ └─┘ └┘ ┴
typ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
doc └─┘ └─┘
1102 λ x h, ⟨mem_image_of_mem _ h.left, h.right⟩
id ┴ ┴ └──────────────┘ ┴└───┘ ┴└────┘
src └──────────────┘ └───┘ └────┘
typ ┴ ┴ └──────────────┘ ┴└───┘ ┴└────┘
1103
1104 theorem union_preimage_subset (s : set α) (t : set β) (f : α → β) :
id └─┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ ┴ ┴
1105 s ∪ f ⁻¹' t ⊆ f ⁻¹' (f '' s ∪ t) :=
id ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
src ┴ └─┘ ┴ └─┘ └┘ ┴
typ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ └┘ ┴ ┴ ┴
doc └─┘ └─┘
1106 λ x h, or.elim h (λ l, or.inl $ mem_image_of_mem _ l) (λ r, or.inr r)
id ┴ ┴ └─────┘ ┴ ┴ └────┘ └──────────────┘ ┴ ┴ └────┘ ┴
src └─────┘ └────┘ └──────────────┘ └────┘
typ ┴ ┴ └─────┘ ┴ ┴ └────┘ └──────────────┘ ┴ ┴ └────┘ ┴
1107
1108 theorem subset_image_union (f : α → β) (s : set α) (t : set β) :
id ┴ ┴ └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ ┴ ┴ └─┘ ┴ └─┘ ┴
1109 f '' (s ∪ f ⁻¹' t) ⊆ f '' s ∪ t :=
id ┴ └┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src └┘ ┴ └─┘ ┴ └┘ ┴
typ ┴ └┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴
doc └─┘
1110 image_subset_iff.2 (union_preimage_subset _ _ _)
id └──────────────┘┴ └───────────────────┘
src └──────────────┘┴ └───────────────────┘
typ └──────────────┘┴ └───────────────────┘
doc └──────────────┘
1111
1112 lemma preimage_subset_iff {A : set α} {B : set β} {f : α → β} :
id └─┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ ┴ ┴
1113 f⁻¹' B ⊆ A ↔ (∀ a : α, f a ∈ B → a ∈ A) := iff.rfl
id ┴└─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
src └─┘ ┴ ┴ ┴ ┴ └─────┘
typ ┴└─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
doc └─┘
1114
1115 lemma image_eq_image {f : α → β} (hf : injective f) : f '' s = f '' t ↔ s = t :=
id ┴ ┴ └───────┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
src └───────┘ └┘ ┴ └┘ ┴ ┴
typ ┴ ┴ └───────┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
1116 iff.symm $ iff.intro (assume eq, eq ▸ rfl) $ assume eq,
id └──────┘ └───────┘ └┘ └┘ ┴ └─┘ └┘
src └──────┘ └───────┘ └┘ └┘ ┴ └─┘ └┘
typ └──────┘ └───────┘ └┘ └┘ ┴ └─┘ └┘
1117 by rw [← preimage_image_eq s hf, ← preimage_image_eq t hf, eq]
id └───────────────┘ ┴ └┘ └───────────────┘ ┴ └┘ └┘
src └────┘└───────────────┘┴ ┴ └──┘└───────────────┘┴ ┴ └┘└┘└─
typ └────┘└───────────────┘┴┴┴└┘└──┘└───────────────┘┴┴┴└┘└┘└┘└─
doc └────┘ ┴ ┴ └──┘ ┴ ┴ └┘ └─
txt └────┘ ┴ ┴ └──┘ ┴ ┴ └┘ └─
par └────┘ ┴ ┴ └──┘ ┴ ┴ └┘ └─
pid └──┘ ┴ ┴ └──┘ ┴ ┴ └┘ ┴└
st └───────────────────────────┘└────────────────────────┘└──┘┴└
1118
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1119 lemma image_subset_image_iff {f : α → β} (hf : injective f) : f '' s ⊆ f '' t ↔ s ⊆ t :=
id ┴ ┴ └───────┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
src └───────┘ └┘ ┴ └┘ ┴ ┴
typ ┴ ┴ └───────┘ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴
1120 begin
st └─────
1121 refine (iff.symm $ iff.intro (image_subset f) $ assume h, _),
id └──────┘ └───────┘ └──────────┘ ┴
src └─────┘ └──────┘┴ ┴└───────┘┴ └──────────┘┴ └┘ ┴ └────┘
typ └─────┘ └──────┘┴ ┴└───────┘┴ └──────────┘┴┴└┘ ┴ └────┘
doc └─────┘ ┴ ┴ ┴ ┴ └┘ ┴ └────┘
txt └─────┘ ┴ ┴ ┴ ┴ └┘ ┴ └────┘
par └─────┘ ┴ ┴ ┴ ┴ └┘ ┴ └────┘
pid ┴ ┴ ┴ ┴ ┴ └┘ ┴ └────┘
st ─────────────────────────────────────────────────────────────┘└─
1122 rw [← preimage_image_eq s hf, ← preimage_image_eq t hf],
id └───────────────┘ ┴ └┘ └───────────────┘ ┴ └┘
src └────┘└───────────────┘┴ ┴ └──┘└───────────────┘┴ ┴ ┴
typ └────┘└───────────────┘┴┴┴└┘└──┘└───────────────┘┴┴┴└┘┴
doc └────┘ ┴ ┴ └──┘ ┴ ┴ ┴
txt └────┘ ┴ ┴ └──┘ ┴ ┴ ┴
par └────┘ ┴ ┴ └──┘ ┴ ┴ ┴
pid └──┘ ┴ ┴ └──┘ ┴ ┴ ┴
st ─────────────────────────────┘└────────────────────────┘└──
1123 exact preimage_mono h
id └───────────┘ ┴
src └────┘└───────────┘┴ ┴
typ └────┘└───────────┘┴┴┴
doc └────┘ ┴ ┴
txt └────┘ ┴ ┴
par └────┘ ┴ ┴
pid ┴ ┴ ┴
st ───────────────────────┘
1124 end
st └─┘
1125
1126 lemma injective_image {f : α → β} (hf : injective f) : injective (('') f) :=
id ┴ ┴ └───────┘ ┴ └───────┘ ┴ ┴
src └───────┘ └───────┘ ┴
typ ┴ ┴ └───────┘ ┴ └───────┘ ┴ ┴
1127 assume s t, (image_eq_image hf).1
id ┴ ┴ └────────────┘ └┘ ┴
src └────────────┘ ┴
typ ┴ ┴ └────────────┘ └┘ ┴
1128
1129 lemma prod_quotient_preimage_eq_image [s : setoid α] (g : quotient s → β) {h : α → β}
id └────┘ ┴ └──────┘ ┴ ┴ ┴ ┴
src └────┘ └──────┘
typ └────┘ ┴ └──────┘ ┴ ┴ ┴ ┴
1130 (Hh : h = g ∘ quotient.mk) (r : set (β × β)) :
id ┴ ┴ ┴ ┴ └─────────┘ └─┘ ┴ ┴ ┴
src ┴ ┴ └─────────┘ └─┘ ┴
typ ┴ ┴ ┴ ┴ └─────────┘ └─┘ ┴ ┴ ┴
1131 {x : quotient s × quotient s | (g x.1, g x.2) ∈ r} =
id ┴ └──────┘ ┴ ┴ └──────┘ ┴ ┴┴ ┴┴ ┴ ┴┴ ┴ ┴ ┴
src ┴ └──────┘ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
typ ┴ └──────┘ ┴ ┴ └──────┘ ┴ ┴┴ ┴┴ ┴ ┴┴ ┴ ┴ ┴
1132 (λ a : α × α, (⟦a.1⟧, ⟦a.2⟧)) '' ((λ a : α × α, (h a.1, h a.2)) ⁻¹' r) :=
id ┴ ┴ ┴ ┴┴┴┴ ┴ ┴┴┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴┴ └─┘ ┴
src ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴┴┴┴ ┴ ┴┴┴ ┴ └┘ ┴ ┴ ┴ ┴┴ ┴┴ ┴ ┴┴ └─┘ ┴
doc └─┘
1133 Hh.symm ▸ set.ext (λ ⟨a₁, a₂⟩, ⟨quotient.induction_on₂ a₁ a₂
id └┘└───┘ ┴ └─────┘ ┴└┘ └┘ └────────────────────┘
src └───┘ ┴ └─────┘ └────────────────────┘
typ └┘└───┘ ┴ └─────┘ ┴└┘ └┘ └────────────────────┘
1134 (λ a₁ a₂ h, ⟨(a₁, a₂), h, rfl⟩),
id └┘ └┘ ┴ ┴└┘ └┘ ┴ └─┘
src ┴ └─┘
typ └┘ └┘ ┴ ┴└┘ └┘ ┴ └─┘
1135 λ ⟨⟨b₁, b₂⟩, h₁, h₂⟩, show (g a₁, g a₂) ∈ r, from
id ┴ └┘ └┘ └┘ └┘ ┴┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ └┘ └┘ └┘ └┘ ┴┴ ┴ ┴ ┴
1136 have h₃ : ⟦b₁⟧ = a₁ ∧ ⟦b₂⟧ = a₂ := prod.ext_iff.1 h₂,
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──────────┘┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──────────┘┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └──────────┘┴
1137 h₃.1 ▸ h₃.2 ▸ h₁⟩)
id └┘┴ ┴ └┘┴ ┴
src ┴ ┴ ┴ ┴
typ └┘┴ ┴ └┘┴ ┴
1138
1139 /-- Restriction of `f` to `s` factors through `s.image_factorization f : s → f '' s`. -/
1140 def image_factorization (f : α → β) (s : set α) : s → f '' s :=
id ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴
src └─┘ └┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴
1141 λ p, ⟨f p.1, mem_image_of_mem f p.2⟩
id ┴ ┴ ┴┴ └──────────────┘ ┴ ┴┴
src ┴ └──────────────┘ ┴
typ ┴ ┴ ┴┴ └──────────────┘ ┴ ┴┴
1142
1143 lemma image_factorization_eq {f : α → β} {s : set α} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1144 subtype.val ∘ image_factorization f s = f ∘ subtype.val :=
id └─────────┘ ┴ └─────────────────┘ ┴ ┴ ┴ ┴ ┴ └─────────┘
src └─────────┘ ┴ └─────────────────┘ ┴ ┴ └─────────┘
typ └─────────┘ ┴ └─────────────────┘ ┴ ┴ ┴ ┴ ┴ └─────────┘
doc └─────────────────┘
1145 funext $ λ p, rfl
id └────┘ ┴ └─┘
src └────┘ └─┘
typ └────┘ ┴ └─┘
1146
1147 lemma surjective_onto_image {f : α → β} {s : set α} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1148 surjective (image_factorization f s) :=
id └────────┘ └─────────────────┘ ┴ ┴
src └────────┘ └─────────────────┘
typ └────────┘ └─────────────────┘ ┴ ┴
doc └─────────────────┘
1149 λ ⟨_, ⟨a, ha, rfl⟩⟩, ⟨⟨a, ha⟩, rfl⟩
id ┴ ┴ └┘ └─┘ └─┘
src └─┘ └─┘
typ ┴ ┴ └┘ └─┘ └─┘
1150
1151 end image
1152
1153 /-! ### Subsingleton -/
1154
1155 /-- A set `s` is a `subsingleton`, if it has at most one element. -/
1156 protected def subsingleton (s : set α) : Prop :=
id └─┘ ┴
src └─┘
typ └─┘ ┴
1157 ∀ ⦃x⦄ (hx : x ∈ s) ⦃y⦄ (hy : y ∈ s), x = y
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1158
1159 lemma subsingleton.mono (ht : t.subsingleton) (hst : s ⊆ t) : s.subsingleton :=
id ┴└───────────┘ ┴ ┴ ┴ ┴└───────────┘
src └───────────┘ ┴ └───────────┘
typ ┴└───────────┘ ┴ ┴ ┴ ┴└───────────┘
doc └───────────┘ └───────────┘
1160 λ x hx y hy, ht (hst hx) (hst hy)
id ┴ └┘ ┴ └┘ └┘ └─┘ └┘ └─┘ └┘
typ ┴ └┘ ┴ └┘ └┘ └─┘ └┘ └─┘ └┘
1161
1162 lemma subsingleton.image (hs : s.subsingleton) (f : α → β) : (f '' s).subsingleton :=
id ┴└───────────┘ ┴ ┴ ┴ └┘ ┴ └──────────┘
src └───────────┘ └┘ └──────────┘
typ ┴└───────────┘ ┴ ┴ ┴ └┘ ┴ └──────────┘
doc └───────────┘ └──────────┘
1163 λ _ ⟨x, hx, Hx⟩ _ ⟨y, hy, Hy⟩, Hx ▸ Hy ▸ congr_arg f (hs hx hy)
id ┴ ┴ └┘ └┘ ┴ ┴ └┘ └┘ ┴ ┴ └───────┘ ┴ └┘
src ┴ ┴ └───────┘
typ ┴ ┴ └┘ └┘ ┴ ┴ └┘ └┘ ┴ ┴ └───────┘ ┴ └┘
1164
1165 lemma subsingleton.eq_singleton_of_mem (hs : s.subsingleton) {x:α} (hx : x ∈ s) :
id ┴└───────────┘ ┴ ┴ ┴ ┴
src └───────────┘ ┴
typ ┴└───────────┘ ┴ ┴ ┴ ┴
doc └───────────┘
1166 s = {x} :=
id ┴ ┴ ┴┴
src ┴ ┴
typ ┴ ┴ ┴┴
1167 ext $ λ y, ⟨λ hy, (hs hx hy) ▸ mem_singleton _, λ hy, (eq_of_mem_singleton hy).symm ▸ hx⟩
id └─┘ ┴ └┘ └┘ └┘ └┘ ┴ └───────────┘ └┘ └─────────────────┘ └┘ └──┘ ┴ └┘
src └─┘ ┴ └───────────┘ └─────────────────┘ └──┘ ┴
typ └─┘ ┴ └┘ └┘ └┘ └┘ ┴ └───────────┘ └┘ └─────────────────┘ └┘ └──┘ ┴ └┘
1168
1169 lemma subsingleton_empty : (∅ : set α).subsingleton := λ x, false.elim
id ┴ └─┘ ┴ └──────────┘ ┴ └────────┘
src ┴ └─┘ └──────────┘ └────────┘
typ ┴ └─┘ ┴ └──────────┘ ┴ └────────┘
doc └──────────┘
1170
1171 lemma subsingleton_singleton {a} : ({a} : set α).subsingleton :=
id ┴┴ └─┘ ┴ └──────────┘
src ┴ └─┘ └──────────┘
typ ┴┴ └─┘ ┴ └──────────┘
doc └──────────┘
1172 λ x hx y hy, (eq_of_mem_singleton hx).symm ▸ (eq_of_mem_singleton hy).symm ▸ rfl
id ┴ └┘ ┴ └┘ └─────────────────┘ └┘ └──┘ ┴ └─────────────────┘ └┘ └──┘ ┴ └─┘
src └─────────────────┘ └──┘ ┴ └─────────────────┘ └──┘ ┴ └─┘
typ ┴ └┘ ┴ └┘ └─────────────────┘ └┘ └──┘ ┴ └─────────────────┘ └┘ └──┘ ┴ └─┘
1173
1174 lemma subsingleton.eq_empty_or_singleton (hs : s.subsingleton) :
id ┴└───────────┘
src └───────────┘
typ ┴└───────────┘
doc └───────────┘
1175 s = ∅ ∨ ∃ x, s = {x} :=
id ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴┴
1176 s.eq_empty_or_nonempty.elim or.inl (λ ⟨x, hx⟩, or.inr ⟨x, hs.eq_singleton_of_mem hx⟩)
id ┴└───────────────────┘└───┘ └────┘ ┴┴ └┘ └────┘ └┘└──────────────────┘
src └───────────────────┘└───┘ └────┘ └────┘ └──────────────────┘
typ ┴└───────────────────┘└───┘ └────┘ ┴┴ └┘ └────┘ └┘└──────────────────┘
1177
1178 theorem univ_eq_true_false : univ = ({true, false} : set Prop) :=
id └──┘ ┴ ┴└──┘┴ └───┘ └─┘
src └──┘ ┴ ┴└──┘┴ └───┘ └─┘
typ └──┘ ┴ ┴└──┘┴ └───┘ └─┘
1179 eq.symm $ eq_univ_of_forall $ classical.cases (by simp) (by simp)
id └─────┘ └───────────────┘ └─────────────┘
src └─────┘ └───────────────┘ └─────────────┘ └──┘ └──┘
typ └─────┘ └───────────────┘ └─────────────┘ └──┘ └──┘
doc └──┘ └──┘
txt └──┘ └──┘
par └──┘ └──┘
st └───┘ └───┘
1180
1181 /-! ### Lemmas about range of a function. -/
1182 section range
1183 variables {f : ι → α}
1184 open function
1185
1186 /-- Range of a function.
1187
1188 This function is more flexible than `f '' univ`, as the image requires that the domain is in Type
1189 and not an arbitrary Sort. -/
1190 def range (f : ι → α) : set α := {x | ∃y, f y = x}
id ┴ ┴ └─┘ ┴ ┴┴ ┴┴┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴┴ ┴┴┴ ┴ ┴ ┴ ┴
1191
1192 @[simp] theorem mem_range {x : α} : x ∈ range f ↔ ∃ y, f y = x := iff.rfl
id ┴ ┴ ┴ └───┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─────┘
src ┴ └───┘ ┴ ┴ ┴ ┴ └─────┘
typ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └─────┘
doc └──┘ └───┘
1193
1194 theorem mem_range_self (i : ι) : f i ∈ range f := ⟨i, rfl⟩
id ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └─┘
src ┴ └───┘ └─┘
typ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └─┘
doc └───┘
1195
1196 theorem forall_range_iff {p : α → Prop} : (∀ a ∈ range f, p a) ↔ (∀ i, p (f i)) :=
id ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───┘ ┴
typ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘
1197 ⟨assume h i, h (f i) (mem_range_self _), assume h a ⟨i, (hi : f i = a)⟩, hi ▸ h i⟩
id ┴ ┴ ┴ ┴ ┴ └────────────┘ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
src └────────────┘ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ └────────────┘ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
1198
1199 theorem exists_range_iff {p : α → Prop} : (∃ a ∈ range f, p a) ↔ (∃ i, p (f i)) :=
id ┴ ┴ ┴ └───┘ ┴┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src ┴ └───┘ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ └───┘ ┴┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
doc └───┘
1200 ⟨assume ⟨a, ⟨i, eq⟩, h⟩, ⟨i, eq.symm ▸ h⟩, assume ⟨i, h⟩, ⟨f i, mem_range_self _, h⟩⟩
id ┴ ┴ └┘ ┴ └───┘ ┴ ┴┴ ┴ ┴ └────────────┘
src └┘ └───┘ ┴ └────────────┘
typ ┴ ┴ └┘ ┴ └───┘ ┴ ┴┴ ┴ ┴ └────────────┘
1201
1202 theorem range_iff_surjective : range f = univ ↔ surjective f :=
id └───┘ ┴ ┴ └──┘ ┴ └────────┘ ┴
src └───┘ ┴ └──┘ ┴ └────────┘
typ └───┘ ┴ ┴ └──┘ ┴ └────────┘ ┴
doc └───┘
1203 eq_univ_iff_forall
id └────────────────┘
src └────────────────┘
typ └────────────────┘
1204
1205 @[simp] theorem range_id : range (@id α) = univ := range_iff_surjective.2 surjective_id
id └───┘ └┘ ┴ ┴ └──┘ └──────────────────┘┴ └───────────┘
src └───┘ └┘ ┴ └──┘ └──────────────────┘┴ └───────────┘
typ └───┘ └┘ ┴ ┴ └──┘ └──────────────────┘┴ └───────────┘
doc └──┘ └───┘
1206
1207 theorem range_inl_union_range_inr : range (@sum.inl α β) ∪ range sum.inr = univ :=
id └───┘ └─────┘ ┴ ┴ ┴ └───┘ └─────┘ ┴ └──┘
src └───┘ └─────┘ ┴ └───┘ └─────┘ ┴ └──┘
typ └───┘ └─────┘ ┴ ┴ ┴ └───┘ └─────┘ ┴ └──┘
doc └───┘ └───┘
1208 ext $ λ x, by cases x; simp
id └─┘ ┴ ┴
src └─┘ └────┘ └────
typ └─┘ ┴ └────┘┴ └────
doc └────┘ └────
txt └────┘ └────
par └────┘ └────
pid ┴ └
st └──────────────
1209
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1210 @[simp] theorem range_quot_mk (r : α → α → Prop) : range (quot.mk r) = univ :=
id ┴ ┴ └───┘ └─────┘ ┴ ┴ └──┘
src └───┘ ┴ └──┘
typ ┴ ┴ └───┘ └─────┘ ┴ ┴ └──┘
doc └──┘ └───┘
1211 range_iff_surjective.2 quot.exists_rep
id └──────────────────┘┴ └─────────────┘
src └──────────────────┘┴ └─────────────┘
typ └──────────────────┘┴ └─────────────┘
1212
1213 @[simp] theorem image_univ {ι : Type*} {f : ι → β} : f '' univ = range f :=
id ┴ ┴ ┴ └┘ └──┘ ┴ └───┘ ┴
src └┘ └──┘ ┴ └───┘
typ ┴ ┴ ┴ └┘ └──┘ ┴ └───┘ ┴
doc └──┘ └───┘
1214 ext $ by simp [image, range]
id └─┘ └───┘ └───┘
src └─┘ └────┘└───┘└┘└───┘└─
typ └─┘ └────┘└───┘└┘└───┘└─
doc └────┘ └┘└───┘└─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └────────────────────
1215
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1216 theorem image_subset_range {ι : Type*} (f : ι → β) (s : set ι) : f '' s ⊆ range f :=
id ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ └───┘ ┴
src └─┘ └┘ ┴ └───┘
typ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ └───┘ ┴
doc └───┘
1217 by rw ← image_univ; exact image_subset _ (subset_univ _)
id └────────┘ └──────────┘ └─────────┘
src └───┘└────────┘ └────┘└──────────┘└─┘ └─────────┘└───
typ └───┘└────────┘ └────┘└──────────┘└─┘ └─────────┘└───
doc └───┘ └────┘ └─┘ └───
txt └───┘ └────┘ └─┘ └───
par └───┘ └────┘ └─┘ └───
pid └─┘ ┴ └─┘ └─┘└
st └──────────────────────────────────────────────────────
1218
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1219 theorem range_comp {g : α → β} : range (g ∘ f) = g '' range f :=
id ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ └┘ └───┘ ┴
src └───┘ ┴ ┴ └┘ └───┘
typ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ └┘ └───┘ ┴
doc └───┘ └───┘
1220 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
1221 (forall_range_iff.mpr $ assume i, mem_image_of_mem g (mem_range_self _))
id └──────────────┘└──┘ ┴ └──────────────┘ ┴ └────────────┘
src └──────────────┘└──┘ └──────────────┘ └────────────┘
typ └──────────────┘└──┘ ┴ └──────────────┘ ┴ └────────────┘
1222 (ball_image_iff.mpr $ forall_range_iff.mpr mem_range_self)
id └────────────┘└──┘ └──────────────┘└──┘ └────────────┘
src └────────────┘└──┘ └──────────────┘└──┘ └────────────┘
typ └────────────┘└──┘ └──────────────┘└──┘ └────────────┘
1223
1224 theorem range_subset_iff {s : set α} : range f ⊆ s ↔ ∀ y, f y ∈ s :=
id └─┘ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ └───┘ ┴ ┴ ┴
typ └─┘ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘
1225 forall_range_iff
id └──────────────┘
src └──────────────┘
typ └──────────────┘
1226
1227 lemma range_comp_subset_range (f : α → β) (g : β → γ) : range (g ∘ f) ⊆ range g :=
id ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ └───┘ ┴
src └───┘ ┴ ┴ └───┘
typ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ └───┘ ┴
doc └───┘ └───┘
1228 by rw range_comp; apply image_subset_range
id └────────┘ └────────────────┘
src └─┘└────────┘ └────┘└────────────────┘└
typ └─┘└────────┘ └────┘└────────────────┘└
doc └─┘ └────┘ └
txt └─┘ └────┘ └
par └─┘ └────┘ └
pid ┴ ┴ └
st └────────────────────────────────────────
1229
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1230 lemma range_nonempty_iff_nonempty : (range f).nonempty ↔ nonempty ι :=
id └───┘ ┴ └──────┘ ┴ └──────┘ ┴
src └───┘ └──────┘ ┴ └──────┘
typ └───┘ ┴ └──────┘ ┴ └──────┘ ┴
doc └───┘ └──────┘
1231 ⟨λ ⟨y, x, hxy⟩, ⟨x⟩, λ ⟨x⟩, ⟨f x, mem_range_self x⟩⟩
id ┴ ┴ ┴┴ ┴ └────────────┘
src └────────────┘
typ ┴ ┴ ┴┴ ┴ └────────────┘
1232
1233 lemma range_nonempty [h : nonempty ι] (f : ι → α) : (range f).nonempty :=
id └──────┘ ┴ ┴ ┴ └───┘ ┴ └──────┘
src └──────┘ └───┘ └──────┘
typ └──────┘ ┴ ┴ ┴ └───┘ ┴ └──────┘
doc └───┘ └──────┘
1234 range_nonempty_iff_nonempty.2 h
id └─────────────────────────┘┴ ┴
src └─────────────────────────┘┴
typ └─────────────────────────┘┴ ┴
1235
1236 @[simp] lemma range_eq_empty {f : ι → α} : range f = ∅ ↔ ¬ nonempty ι :=
id ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
src └───┘ ┴ ┴ ┴ ┴ └──────┘
typ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴
doc └──┘ └───┘
1237 not_nonempty_iff_eq_empty.symm.trans $ not_congr range_nonempty_iff_nonempty
id └───────────────────────┘└───┘└────┘ └───────┘ └─────────────────────────┘
src └───────────────────────┘└───┘└────┘ └───────┘ └─────────────────────────┘
typ └───────────────────────┘└───┘└────┘ └───────┘ └─────────────────────────┘
1238
1239 theorem image_preimage_eq_inter_range {f : α → β} {t : set β} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1240 f '' (f ⁻¹' t) = t ∩ range f :=
id ┴ └┘ ┴ └─┘ ┴ ┴ ┴ ┴ └───┘ ┴
src └┘ └─┘ ┴ ┴ └───┘
typ ┴ └┘ ┴ └─┘ ┴ ┴ ┴ ┴ └───┘ ┴
doc └─┘ └───┘
1241 ext $ assume x, ⟨assume ⟨x, hx, heq⟩, heq ▸ ⟨hx, mem_range_self _⟩,
id └─┘ ┴ ┴ └┘ └─┘ ┴ └────────────┘
src └─┘ └─┘ ┴ └────────────┘
typ └─┘ ┴ ┴ └┘ └─┘ ┴ └────────────┘
1242 assume ⟨hx, ⟨y, h_eq⟩⟩, h_eq ▸ mem_image_of_mem f $
id ┴ ┴ └──┘ ┴ └──────────────┘ ┴
src ┴ └──────────────┘
typ ┴ ┴ └──┘ ┴ └──────────────┘ ┴
1243 show y ∈ f ⁻¹' t, by simp [preimage, h_eq, hx]⟩
id ┴ ┴ └─┘ ┴ └──────┘ └──┘ └┘
src ┴ └─┘ └────┘└──────┘└┘ └┘ ┴
typ ┴ ┴ └─┘ ┴ └────┘└──────┘└┘└──┘└┘└┘┴
doc └─┘ └────┘└──────┘└┘ └┘ ┴
txt └────┘ └┘ └┘ ┴
par └────┘ └┘ └┘ ┴
pid ┴┴ └┘ └┘ ┴
st └────────────────────────┘
1244
1245 lemma image_preimage_eq_of_subset {f : α → β} {s : set β} (hs : s ⊆ range f) :
id ┴ ┴ └─┘ ┴ ┴ ┴ └───┘ ┴
src └─┘ ┴ └───┘
typ ┴ ┴ └─┘ ┴ ┴ ┴ └───┘ ┴
doc └───┘
1246 f '' (f ⁻¹' s) = s :=
id ┴ └┘ ┴ └─┘ ┴ ┴ ┴
src └┘ └─┘ ┴
typ ┴ └┘ ┴ └─┘ ┴ ┴ ┴
doc └─┘
1247 by rw [image_preimage_eq_inter_range, inter_eq_self_of_subset_left hs]
id └───────────────────────────┘ └──────────────────────────┘ └┘
src └──┘└───────────────────────────┘└┘└──────────────────────────┘┴ └─
typ └──┘└───────────────────────────┘└┘└──────────────────────────┘┴└┘└─
doc └──┘ └┘ ┴ └─
txt └──┘ └┘ ┴ └─
par └──┘ └┘ ┴ └─
pid └┘ └┘ ┴ ┴└
st └────────────────────────────────┘└───────────────────────────────┘┴└
1248
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1249 lemma preimage_subset_preimage_iff {s t : set α} {f : β → α} (hs : s ⊆ range f) :
id └─┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴
src └─┘ ┴ └───┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴
doc └───┘
1250 f ⁻¹' s ⊆ f ⁻¹' t ↔ s ⊆ t :=
id ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └─┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └─┘ └─┘
1251 begin
st └─────
1252 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
1253 { intros h x hx, rcases hs hx with ⟨y, rfl⟩, exact h hx },
id └┘ └┘ ┴ └┘
src └───────────┘ └─────┘ ┴ └────────────┘ └────┘ ┴ ┴
typ └───────────┘ └─────┘└┘┴└┘└────────────┘ └────┘┴┴└┘┴
doc └───────────┘ └─────┘ ┴ └────────────┘ └────┘ ┴ ┴
txt └───────────┘ └─────┘ ┴ └────────────┘ └────┘ ┴ ┴
par └───────────┘ └─────┘ ┴ └────────────┘ └────┘ ┴ ┴
pid └─────┘ ┴ ┴ └────────────┘ ┴ ┴ ┴
st ───┘└───────────┘└──────────────────────────┘└───────────┘└┘└
1254 intros h x, apply h
src └────────┘ └────┘ ┴
typ └────────┘ └────┘ ┴
doc └────────┘ └────┘ ┴
txt └────────┘ └────┘ ┴
par └────────┘ └────┘ ┴
pid └──┘ ┴ ┴
st ───────────┘└────────┘
1255 end
st └─┘
1256
1257 lemma preimage_eq_preimage' {s t : set α} {f : β → α} (hs : s ⊆ range f) (ht : t ⊆ range f) :
id └─┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴
src └─┘ ┴ └───┘ ┴ └───┘
typ └─┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴
doc └───┘ └───┘
1258 f ⁻¹' s = f ⁻¹' t ↔ s = t :=
id ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ └─┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └─┘ └─┘
1259 begin
st └─────
1260 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
1261 { intro h, apply subset.antisymm, rw [←preimage_subset_preimage_iff hs, h],
id └─────────────┘ └──────────────────────────┘ └┘ ┴
src └─────┘ └────┘└─────────────┘ └───┘└──────────────────────────┘┴ └┘ ┴
typ └─────┘ └────┘└─────────────┘ └───┘└──────────────────────────┘┴└┘└┘┴┴
doc └─────┘ └────┘ └───┘ ┴ └┘ ┴
txt └─────┘ └────┘ └───┘ ┴ └┘ ┴
par └─────┘ └────┘ └───┘ ┴ └┘ ┴
pid └┘ ┴ └─┘ ┴ └┘ ┴
st ───┘└─────┘└─────────────────────┘└────────────────────────────────────┘└─┘└──
1262 rw [←preimage_subset_preimage_iff ht, h] },
id └──────────────────────────┘ └┘ ┴
src └───┘└──────────────────────────┘┴ └┘ └┘
typ └───┘└──────────────────────────┘┴└┘└┘┴└┘
doc └───┘ ┴ └┘ └┘
txt └───┘ ┴ └┘ └┘
par └───┘ ┴ └┘ └┘
pid └─┘ ┴ └┘ ┴┴
st ───────────────────────────────────────┘└─┘┴┴└┘└
1263 rintro rfl, refl
src └────────┘ └───┘
typ └────────┘ └───┘
doc └────────┘ └───┘
txt └────────┘ └───┘
par └────────┘ └───┘
pid └──┘ ┴
st ───────────┘└─────┘
1264 end
st └─┘
1265
1266 theorem preimage_inter_range {f : α → β} {s : set β} : f ⁻¹' (s ∩ range f) = f ⁻¹' s :=
id ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ └───┘ ┴ ┴ ┴ └─┘ ┴
src └─┘ └─┘ ┴ └───┘ ┴ └─┘
typ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ └───┘ ┴ ┴ ┴ └─┘ ┴
doc └─┘ └───┘ └─┘
1267 set.ext $ λ x, and_iff_left ⟨x, rfl⟩
id └─────┘ ┴ └──────────┘ ┴ └─┘
src └─────┘ └──────────┘ └─┘
typ └─────┘ ┴ └──────────┘ ┴ └─┘
1268
1269 theorem preimage_image_preimage {f : α → β} {s : set β} :
id ┴ ┴ └─┘ ┴
src └─┘
typ ┴ ┴ └─┘ ┴
1270 f ⁻¹' (f '' (f ⁻¹' s)) = f ⁻¹' s :=
id ┴ └─┘ ┴ └┘ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴
src └─┘ └┘ └─┘ ┴ └─┘
typ ┴ └─┘ ┴ └┘ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴
doc └─┘ └─┘ └─┘
1271 by rw [image_preimage_eq_inter_range, preimage_inter_range]
id └───────────────────────────┘ └──────────────────┘
src └──┘└───────────────────────────┘└┘└──────────────────┘└─
typ └──┘└───────────────────────────┘└┘└──────────────────┘└─
doc └──┘ └┘ └─
txt └──┘ └┘ └─
par └──┘ └┘ └─
pid └┘ └┘ ┴└
st └────────────────────────────────┘└────────────────────┘┴└
1272
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1273 @[simp] theorem quot_mk_range_eq [setoid α] : range (λx : α, ⟦x⟧) = univ :=
id └────┘ ┴ └───┘ ┴ ┴┴┴ ┴ └──┘
src └────┘ └───┘ ┴ ┴ ┴ └──┘
typ └────┘ ┴ └───┘ ┴ ┴┴┴ ┴ └──┘
doc └──┘ └───┘
1274 range_iff_surjective.2 quot.exists_rep
id └──────────────────┘┴ └─────────────┘
src └──────────────────┘┴ └─────────────┘
typ └──────────────────┘┴ └─────────────┘
1275
1276 lemma range_const_subset {c : α} : range (λx:ι, c) ⊆ {c} :=
id ┴ └───┘ ┴ ┴ ┴ ┴┴
src └───┘ ┴ ┴
typ ┴ └───┘ ┴ ┴ ┴ ┴┴
doc └───┘
1277 range_subset_iff.2 $ λ x, or.inl rfl
id └──────────────┘┴ ┴ └────┘ └─┘
src └──────────────┘┴ └────┘ └─┘
typ └──────────────┘┴ ┴ └────┘ └─┘
1278
1279 @[simp] lemma range_const : ∀ [nonempty ι] {c : α}, range (λx:ι, c) = {c}
id ┴└──────┘ ┴ ┴ └───┘ ┴ ┴ ┴ ┴┴
src └──────┘ └───┘ ┴ ┴
typ ┴└──────┘ ┴ ┴ └───┘ ┴ ┴ ┴ ┴┴
doc └──┘ └───┘
1280 | ⟨x⟩ c := subset.antisymm range_const_subset $
id ┴ └─────────────┘ └────────────────┘
src └─────────────┘ └────────────────┘
typ ┴ └─────────────┘ └────────────────┘
1281 assume y hy, (mem_singleton_iff.1 hy).symm ▸ mem_range_self x
id ┴ └┘ └───────────────┘┴ └┘ └──┘ ┴ └────────────┘
src └───────────────┘┴ └──┘ ┴ └────────────┘
typ ┴ └┘ └───────────────┘┴ └┘ └──┘ ┴ └────────────┘
1282
1283 /-- Any map `f : ι → β` factors through a map `range_factorization f : ι → range f`. -/
1284 def range_factorization (f : ι → β) : ι → range f :=
id ┴ ┴ ┴ └───┘ ┴
src └───┘
typ ┴ ┴ ┴ └───┘ ┴
doc └───┘
1285 λ i, ⟨f i, mem_range_self i⟩
id ┴ ┴ ┴ └────────────┘ ┴
src └────────────┘
typ ┴ ┴ ┴ └────────────┘ ┴
1286
1287 lemma range_factorization_eq {f : ι → β} :
id ┴ ┴
typ ┴ ┴
1288 subtype.val ∘ range_factorization f = f :=
id └─────────┘ ┴ └─────────────────┘ ┴ ┴ ┴
src └─────────┘ ┴ └─────────────────┘ ┴
typ └─────────┘ ┴ └─────────────────┘ ┴ ┴ ┴
doc └─────────────────┘
1289 funext $ λ i, rfl
id └────┘ ┴ └─┘
src └────┘ └─┘
typ └────┘ ┴ └─┘
1290
1291 lemma surjective_onto_range : surjective (range_factorization f) :=
id └────────┘ └─────────────────┘ ┴
src └────────┘ └─────────────────┘
typ └────────┘ └─────────────────┘ ┴
doc └─────────────────┘
1292 λ ⟨_, ⟨i, rfl⟩⟩, ⟨i, rfl⟩
id ┴ ┴ └─┘ └─┘
src └─┘ └─┘
typ ┴ ┴ └─┘ └─┘
1293
1294 lemma image_eq_range (f : α → β) (s : set α) : f '' s = range (λ(x : s), f x.1) :=
id ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ └───┘ ┴ ┴ ┴┴
src └─┘ └┘ ┴ └───┘ ┴
typ ┴ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ └───┘ ┴ ┴ ┴┴
doc └───┘
1295 by { ext, split, rintro ⟨x, h1, h2⟩, exact ⟨⟨x, h1⟩, h2⟩, rintro ⟨⟨x, h1⟩, h2⟩, exact ⟨x, h1, h2⟩ }
id ┴ └┘ └┘ ┴ └┘ └┘
src └─┘ └───┘ └────────────────┘ └────┘ └┘ └─┘ ┴ └──────────────────┘ └────┘ └┘ └┘ └┘
typ └─┘ └───┘ └────────────────┘ └────┘ ┴└┘└┘└─┘└┘┴ └──────────────────┘ └────┘ ┴└┘└┘└┘└┘└┘
doc └─┘ └───┘ └────────────────┘ └────┘ └┘ └─┘ ┴ └──────────────────┘ └────┘ └┘ └┘ └┘
txt └─┘ └───┘ └────────────────┘ └────┘ └┘ └─┘ ┴ └──────────────────┘ └────┘ └┘ └┘ └┘
par └─┘ └───┘ └────────────────┘ └────┘ └┘ └─┘ ┴ └──────────────────┘ └────┘ └┘ └┘ └┘
pid └──────────┘ ┴ └┘ └─┘ ┴ └────────────┘ ┴ └┘ └┘ ┴┴
st └────┘└─────┘└──────────────────┘└───────────────────┘└────────────────────┘└──────────────────┘└┘
1296
1297 @[simp] lemma sum.elim_range {α β γ : Type*} (f : α → γ) (g : β → γ) :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
doc └──┘
1298 range (sum.elim f g) = range f ∪ range g :=
id └───┘ └──────┘ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
src └───┘ └──────┘ ┴ └───┘ ┴ └───┘
typ └───┘ └──────┘ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
doc └───┘ └───┘ └───┘
1299 by simp [set.ext_iff, mem_range]
id └─────────┘ └───────┘
src └────┘└─────────┘└┘└───────┘└─
typ └────┘└─────────┘└┘└───────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └──────────────────────────────
1300
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1301 lemma range_ite_subset' {p : Prop} [decidable p] {f g : α → β} :
id └───────┘ ┴ ┴ ┴
src └───────┘
typ └───────┘ ┴ ┴ ┴
1302 range (if p then f else g) ⊆ range f ∪ range g :=
id └───┘ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
src └───┘ ┴ └───┘ ┴ └───┘
typ └───┘ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
doc └───┘ └───┘ └───┘
1303 begin
st └─────
1304 by_cases h : p, {rw if_pos h, exact subset_union_left _ _},
id ┴ └────┘ ┴ └───────────────┘
src └───────┘ └─┘ └─┘└────┘┴ └────┘└───────────────┘└──┘
typ └───────┘ └─┘┴ └─┘└────┘┴┴ └────┘└───────────────┘└──┘
doc └───────┘ └─┘ └─┘ ┴ └────┘ └──┘
txt └───────┘ └─┘ └─┘ ┴ └────┘ └──┘
par └───────┘ └─┘ └─┘ ┴ └────┘ └──┘
pid ┴ └─┘ ┴ ┴ ┴ └──┘
st ───────────────┘└────┘└────┘└┘└───────────────────────────┘└┘└
1305 {rw if_neg h, exact subset_union_right _ _}
id └────┘ ┴ └────────────────┘
src └─┘└────┘┴ └────┘└────────────────┘└──┘
typ └─┘└────┘┴┴ └────┘└────────────────┘└──┘
doc └─┘ ┴ └────┘ └──┘
txt └─┘ ┴ └────┘ └──┘
par └─┘ ┴ └────┘ └──┘
pid ┴ ┴ ┴ └──┘
st ─────────────┘└────────────────────────────┘└─
1306 end
st ──┘
1307
1308 lemma range_ite_subset {p : α → Prop} [decidable_pred p] {f g : α → β} :
id ┴ └────────────┘ ┴ ┴ ┴
src └────────────┘
typ ┴ └────────────┘ ┴ ┴ ┴
1309 range (λ x, if p x then f x else g x) ⊆ range f ∪ range g :=
id └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
src └───┘ ┴ └───┘ ┴ └───┘
typ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ └───┘ ┴
doc └───┘ └───┘ └───┘
1310 begin
st └─────
1311 rw range_subset_iff, intro x, by_cases h : p x,
id └──────────────┘ ┴ ┴
src └─┘└──────────────┘ └─────┘ └───────┘ └─┘ ┴
typ └─┘└──────────────┘ └─────┘ └───────┘ └─┘┴┴┴
doc └─┘ └─────┘ └───────┘ └─┘ ┴
txt └─┘ └─────┘ └───────┘ └─┘ ┴
par └─┘ └─────┘ └───────┘ └─┘ ┴
pid ┴ └┘ ┴ └─┘ ┴
st ────────────────────┘└───────┘└────────────────┘└─
1312 simp [if_pos h, mem_union, mem_range_self],
id └────┘ ┴ └───────┘ └────────────┘
src └────┘└────┘┴ └┘└───────┘└┘└────────────┘┴
typ └────┘└────┘┴┴└┘└───────┘└┘└────────────┘┴
doc └────┘ ┴ └┘ └┘ ┴
txt └────┘ ┴ └┘ └┘ ┴
par └────┘ ┴ └┘ └┘ ┴
pid ┴┴ ┴ └┘ └┘ ┴
st ───────────────────────────────────────────┘└─
1313 simp [if_neg h, mem_union, mem_range_self]
id └────┘ ┴ └───────┘ └────────────┘
src └────┘└────┘┴ └┘└───────┘└┘└────────────┘└┘
typ └────┘└────┘┴┴└┘└───────┘└┘└────────────┘└┘
doc └────┘ ┴ └┘ └┘ └┘
txt └────┘ ┴ └┘ └┘ └┘
par └────┘ ┴ └┘ └┘ └┘
pid ┴┴ ┴ └┘ └┘ ┴┴
st ────────────────────────────────────────────┘
1314 end
st └─┘
1315
1316 end range
1317
1318 /-- The set `s` is pairwise `r` if `r x y` for all *distinct* `x y ∈ s`. -/
1319 def pairwise_on (s : set α) (r : α → α → Prop) := ∀ x ∈ s, ∀ y ∈ s, x ≠ y → r x y
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1320
1321 theorem pairwise_on.mono {s t : set α} {r}
id └─┘ ┴
src └─┘
typ └─┘ ┴
1322 (h : t ⊆ s) (hp : pairwise_on s r) : pairwise_on t r :=
id ┴ ┴ ┴ └─────────┘ ┴ ┴ └─────────┘ ┴ ┴
src ┴ └─────────┘ └─────────┘
typ ┴ ┴ ┴ └─────────┘ ┴ ┴ └─────────┘ ┴ ┴
doc └─────────┘ └─────────┘
1323 λ x xt y yt, hp x (h xt) y (h yt)
id ┴ └┘ ┴ └┘ └┘ ┴ ┴ └┘ ┴ ┴ └┘
typ ┴ └┘ ┴ └┘ └┘ ┴ ┴ └┘ ┴ ┴ └┘
1324
1325 theorem pairwise_on.mono' {s : set α} {r r' : α → α → Prop}
id └─┘ ┴ ┴ ┴
src └─┘
typ └─┘ ┴ ┴ ┴
1326 (H : ∀ a b, r a b → r' a b) (hp : pairwise_on s r) : pairwise_on s r' :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ └─────────┘ ┴ ┴ └─────────┘ ┴ └┘
src └─────────┘ └─────────┘
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ └─────────┘ ┴ ┴ └─────────┘ ┴ └┘
doc └─────────┘ └─────────┘
1327 λ x xs y ys h, H _ _ (hp x xs y ys h)
id ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ └┘ ┴ └┘ ┴
typ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ └┘ ┴ └┘ ┴
1328
1329 end set
1330 open set
1331
1332 /-! ### Image and preimage on subtypes -/
1333
1334 namespace subtype
1335
1336 variable {α : Type*}
1337
1338 lemma val_image {p : α → Prop} {s : set (subtype p)} :
id ┴ └─┘ └─────┘ ┴
src └─┘ └─────┘
typ ┴ └─┘ └─────┘ ┴
1339 subtype.val '' s = {x | ∃h : p x, (⟨x, h⟩ : subtype p) ∈ s} :=
id └─────────┘ └┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ └─────┘ ┴ ┴ ┴
src └─────────┘ └┘ ┴ ┴ ┴ ┴ └─────┘ ┴
typ └─────────┘ └┘ ┴ ┴ ┴┴ ┴ ┴ ┴┴ ┴ ┴ └─────┘ ┴ ┴ ┴
1340 set.ext $ assume a,
id └─────┘ ┴
src └─────┘
typ └─────┘ ┴
1341 ⟨assume ⟨⟨a', ha'⟩, in_s, h_eq⟩, h_eq ▸ ⟨ha', in_s⟩,
id ┴ └─┘ └──┘ └──┘ ┴
src ┴
typ ┴ └─┘ └──┘ └──┘ ┴
1342 assume ⟨ha, in_s⟩, ⟨⟨a, ha⟩, in_s, rfl⟩⟩
id ┴└┘ └──┘ ┴ └─┘
src └─┘
typ ┴└┘ └──┘ ┴ └─┘
1343
1344 @[simp] lemma val_range {p : α → Prop} :
id ┴
typ ┴
doc └──┘
1345 set.range (@subtype.val _ p) = {x | p x} :=
id └───────┘ └─────────┘ ┴ ┴ ┴┴ ┴ ┴
src └───────┘ └─────────┘ ┴ ┴
typ └───────┘ └─────────┘ ┴ ┴ ┴┴ ┴ ┴
doc └───────┘
1346 by rw ← set.image_univ; simp [-set.image_univ, val_image]
id └────────────┘ └───────┘
src └───┘└────────────┘ └─────────────────────┘└───────┘└─
typ └───┘└────────────┘ └─────────────────────┘└───────┘└─
doc └───┘ └─────────────────────┘ └─
txt └───┘ └─────────────────────┘ └─
par └───┘ └─────────────────────┘ └─
pid └─┘ ┴└────────────────┘ ┴└
st └───────────────────────────────────────────────────────
1347
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1348 @[simp] lemma range_val (s : set α) : range (subtype.val : s → α) = s :=
id └─┘ ┴ └───┘ └─────────┘ ┴ ┴ ┴ ┴
src └─┘ └───┘ └─────────┘ ┴
typ └─┘ ┴ └───┘ └─────────┘ ┴ ┴ ┴ ┴
doc └──┘ └───┘
1349 val_range
id └───────┘
src └───────┘
typ └───────┘
1350
1351 theorem val_image_subset (s : set α) (t : set (subtype s)) : t.image val ⊆ s :=
id └─┘ ┴ └─┘ └─────┘ ┴ ┴└────┘ └─┘ ┴ ┴
src └─┘ └─┘ └─────┘ └────┘ └─┘ ┴
typ └─┘ ┴ └─┘ └─────┘ ┴ ┴└────┘ └─┘ ┴ ┴
1352 λ x ⟨y, yt, yvaleq⟩, by rw ←yvaleq; exact y.property
id ┴ ┴ └────┘ └────────┘
src └──┘ └────┘└────────┘└
typ ┴ ┴ └──┘└────┘ └────┘└────────┘└
doc └──┘ └────┘ └
txt └──┘ └────┘ └
par └──┘ └────┘ └
pid └┘ ┴ └
st └─────────────────────────────
1353
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1354 theorem val_image_univ (s : set α) : @val _ s '' set.univ = s :=
id └─┘ ┴ └─┘ ┴ └┘ └──────┘ ┴ ┴
src └─┘ └─┘ └┘ └──────┘ ┴
typ └─┘ ┴ └─┘ ┴ └┘ └──────┘ ┴ ┴
1355 set.eq_of_subset_of_subset (val_image_subset _ _) (λ x xs, ⟨⟨x, xs⟩, ⟨set.mem_univ _, rfl⟩⟩)
id └────────────────────────┘ └──────────────┘ ┴ └┘ ┴ └┘ └──────────┘ └─┘
src └────────────────────────┘ └──────────────┘ └──────────┘ └─┘
typ └────────────────────────┘ └──────────────┘ ┴ └┘ ┴ └┘ └──────────┘ └─┘
1356
1357 theorem image_preimage_val (s t : set α) :
id └─┘ ┴
src └─┘
typ └─┘ ┴
1358 (@subtype.val _ s) '' ((@subtype.val _ s) ⁻¹' t) = t ∩ s :=
id └─────────┘ ┴ └┘ └─────────┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src └─────────┘ └┘ └─────────┘ └─┘ ┴ ┴
typ └─────────┘ ┴ └┘ └─────────┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └─┘
1359 begin
st └─────
1360 ext x, simp, split,
src └───┘ └──┘ └───┘
typ └───┘ └──┘ └───┘
doc └───┘ └──┘ └───┘
txt └───┘ └──┘ └───┘
par └───┘ └──┘ └───┘
pid └┘
st ──────┘└────┘└─────┘└─
1361 { rintros ⟨y, ys, yt, yx⟩, rw ←yx, exact ⟨yt, ys⟩ },
id └┘ └┘ └┘
src └─────────────────────┘ └──┘ └────┘ └┘ └┘
typ └─────────────────────┘ └──┘└┘ └────┘ └┘└┘└┘└┘
doc └─────────────────────┘ └──┘ └────┘ └┘ └┘
txt └─────────────────────┘ └──┘ └────┘ └┘ └┘
par └─────────────────────┘ └──┘ └────┘ └┘ └┘
pid └──────────────┘ └┘ ┴ └┘ ┴┴
st ───┘└─────────────────────┘└──────┘└───────────────┘└┘└
1362 rintros ⟨xt, xs⟩, exact ⟨x, xs, xt, rfl⟩
id ┴ └┘ └┘ └─┘
src └──────────────┘ └────┘ └┘ └┘ └┘└─┘└┘
typ └──────────────┘ └────┘ ┴└┘└┘└┘└┘└┘└─┘└┘
doc └──────────────┘ └────┘ └┘ └┘ └┘ └┘
txt └──────────────┘ └────┘ └┘ └┘ └┘ └┘
par └──────────────┘ └────┘ └┘ └┘ └┘ └┘
pid └───────┘ ┴ └┘ └┘ └┘ ┴┴
st ─────────────────┘└───────────────────────┘
1363 end
st └─┘
1364
1365 theorem preimage_val_eq_preimage_val_iff (s t u : set α) :
id └─┘ ┴
src └─┘
typ └─┘ ┴
1366 ((@subtype.val _ s) ⁻¹' t = (@subtype.val _ s) ⁻¹' u) ↔ (t ∩ s = u ∩ s) :=
id └─────────┘ ┴ └─┘ ┴ ┴ └─────────┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─────────┘ └─┘ ┴ └─────────┘ └─┘ ┴ ┴ ┴ ┴
typ └─────────┘ ┴ └─┘ ┴ ┴ └─────────┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └─┘ └─┘
1367 begin
st └─────
1368 rw [←image_preimage_val, ←image_preimage_val],
id └────────────────┘ └────────────────┘
src └───┘└────────────────┘└─┘└────────────────┘┴
typ └───┘└────────────────┘└─┘└────────────────┘┴
doc └───┘ └─┘ ┴
txt └───┘ └─┘ ┴
par └───┘ └─┘ ┴
pid └─┘ └─┘ ┴
st ────────────────────────┘└───────────────────┘└──
1369 split, { intro h, rw h },
id ┴
src └───┘ └─────┘ └─┘ ┴
typ └───┘ └─────┘ └─┘┴┴
doc └───┘ └─────┘ └─┘ ┴
txt └───┘ └─────┘ └─┘ ┴
par └───┘ └─────┘ └─┘ ┴
pid └┘ ┴ ┴
st ──────┘└──┘└─────┘└─────┘└┘└
1370 intro h, exact set.injective_image (val_injective) h
id └─────────────────┘ └───────────┘ ┴
src └─────┘ └────┘└─────────────────┘┴ └───────────┘└┘ ┴
typ └─────┘ └────┘└─────────────────┘┴ └───────────┘└┘┴┴
doc └─────┘ └────┘ ┴ └┘ ┴
txt └─────┘ └────┘ ┴ └┘ ┴
par └─────┘ └────┘ ┴ └┘ ┴
pid └┘ ┴ ┴ └┘ ┴
st ────────┘└────────────────────────────────────────────┘
1371 end
st └─┘
1372
1373 lemma exists_set_subtype {t : set α} (p : set α → Prop) :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1374 (∃(s : set t), p (subtype.val '' s)) ↔ ∃(s : set α), s ⊆ t ∧ p s :=
id ┴ └─┘ ┴ ┴ ┴ └─────────┘ └┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ └─────────┘ └┘ ┴ ┴ └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └─────────┘ └┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1375 begin
st └─────
1376 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
1377 { rintro ⟨s, hs⟩, refine ⟨subtype.val '' s, _, hs⟩,
id └─────────┘ └┘ ┴ └┘
src └────────────┘ └─────┘ └─────────┘┴└┘┴ └───┘ ┴
typ └────────────┘ └─────┘ └─────────┘┴└┘┴┴└───┘└┘┴
doc └────────────┘ └─────┘ ┴ ┴ └───┘ ┴
txt └────────────┘ └─────┘ ┴ ┴ └───┘ ┴
par └────────────┘ └─────┘ ┴ ┴ └───┘ ┴
pid └──────┘ ┴ ┴ ┴ └───┘ ┴
st ───┘└────────────┘└────────────────────────────────┘└─
1378 convert image_subset_range _ _, rw [range_val] },
id └────────────────┘ └───────┘
src └──────┘└────────────────┘└──┘ └──┘└───────┘└┘
typ └──────┘└────────────────┘└──┘ └──┘└───────┘└┘
doc └──────┘ └──┘ └──┘ └┘
txt └──────┘ └──┘ └──┘ └┘
par └──────┘ └──┘ └──┘ └┘
pid ┴ └──┘ └┘ ┴┴
st ─────────────────────────────────┘└─────────────┘┴┴└┘└
1379 rintro ⟨s, hs₁, hs₂⟩, refine ⟨subtype.val ⁻¹' s, _⟩,
id └─────────┘ └─┘ ┴
src └──────────────────┘ └─────┘ └─────────┘┴└─┘┴ └──┘
typ └──────────────────┘ └─────┘ └─────────┘┴└─┘┴┴└──┘
doc └──────────────────┘ └─────┘ ┴└─┘┴ └──┘
txt └──────────────────┘ └─────┘ ┴ ┴ └──┘
par └──────────────────┘ └─────┘ ┴ ┴ └──┘
pid └────────────┘ ┴ ┴ ┴ └──┘
st ─────────────────────┘└─────────────────────────────┘└─
1380 rw [image_preimage_eq_of_subset], exact hs₂, rw [range_val], exact hs₁
id └─────────────────────────┘ └─┘ └───────┘ └─┘
src └──┘└─────────────────────────┘┴ └────┘ └──┘└───────┘┴ └────┘ ┴
typ └──┘└─────────────────────────┘┴ └────┘└─┘ └──┘└───────┘┴ └────┘└─┘┴
doc └──┘ ┴ └────┘ └──┘ ┴ └────┘ ┴
txt └──┘ ┴ └────┘ └──┘ ┴ └────┘ ┴
par └──┘ ┴ └────┘ └──┘ ┴ └────┘ ┴
pid └┘ ┴ ┴ └┘ ┴ ┴ ┴
st ────────────────────────────────┘└──────────┘└─────────────┘└───────────┘
1381 end
st └─┘
1382 end subtype
1383
1384 namespace set
1385
1386 section range
1387
1388 variable {α : Type*}
1389
1390 @[simp] lemma subtype.val_range {p : α → Prop} :
id ┴
typ ┴
doc └──┘
1391 range (@subtype.val _ p) = {x | p x} :=
id └───┘ └─────────┘ ┴ ┴ ┴┴ ┴ ┴
src └───┘ └─────────┘ ┴ ┴
typ └───┘ └─────────┘ ┴ ┴ ┴┴ ┴ ┴
doc └───┘
1392 by rw ← image_univ; simp [-image_univ, subtype.val_image]
id └────────┘ └───────────────┘
src └───┘└────────┘ └─────────────────┘└───────────────┘└─
typ └───┘└────────┘ └─────────────────┘└───────────────┘└─
doc └───┘ └─────────────────┘ └─
txt └───┘ └─────────────────┘ └─
par └───┘ └─────────────────┘ └─
pid └─┘ ┴└────────────┘ ┴└
st └───────────────────────────────────────────────────────
1393
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1394 @[simp] lemma range_coe_subtype (s : set α) : range (coe : s → α) = s :=
id └─┘ ┴ └───┘ └─┘ ┴ ┴ ┴ ┴
src └─┘ └───┘ └─┘ ┴
typ └─┘ ┴ └───┘ └─┘ ┴ ┴ ┴ ┴
doc └──┘ └───┘
1395 subtype.val_range
id └───────────────┘
src └───────────────┘
typ └───────────────┘
1396
1397 end range
1398
1399 /-! ### Lemmas about cartesian product of sets -/
1400
1401 section prod
1402
1403 variables {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
1404 variables {s s₁ s₂ : set α} {t t₁ t₂ : set β}
id └─┘ └─┘
src └─┘ └─┘
typ └─┘ └─┘
1405
1406 /-- The cartesian product `prod s t` is the set of `(a, b)`
1407 such that `a ∈ s` and `b ∈ t`. -/
1408 protected def prod (s : set α) (t : set β) : set (α × β) :=
id └─┘ ┴ └─┘ ┴ └─┘ ┴ ┴ ┴
src └─┘ └─┘ └─┘ ┴
typ └─┘ ┴ └─┘ ┴ └─┘ ┴ ┴ ┴
1409 {p | p.1 ∈ s ∧ p.2 ∈ t}
id ┴┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴
1410
1411 lemma prod_eq (s : set α) (t : set β) : set.prod s t = prod.fst ⁻¹' s ∩ prod.snd ⁻¹' t := rfl
id └─┘ ┴ └─┘ ┴ └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴ ┴ └──────┘ └─┘ ┴ └─┘
src └─┘ └─┘ └──────┘ ┴ └──────┘ └─┘ ┴ └──────┘ └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴ ┴ └──────┘ └─┘ ┴ └─┘
doc └──────┘ └─┘ └─┘
1412
1413 theorem mem_prod_eq {p : α × β} : p ∈ set.prod s t = (p.1 ∈ s ∧ p.2 ∈ t) := rfl
id ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘
src ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘
doc └──────┘
1414
1415 @[simp] theorem mem_prod {p : α × β} : p ∈ set.prod s t ↔ p.1 ∈ s ∧ p.2 ∈ t := iff.rfl
id ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └─────┘
src ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ └─────┘
typ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └─────┘
doc └──┘ └──────┘
1416
1417 lemma mk_mem_prod {a : α} {b : β} (a_in : a ∈ s) (b_in : b ∈ t) : (a, b) ∈ set.prod s t := ⟨a_in, b_in⟩
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └──────┘ ┴ ┴ └──┘ └──┘
src ┴ ┴ ┴ ┴ └──────┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ └──────┘ ┴ ┴ └──┘ └──┘
doc └──────┘
1418
1419 lemma prod_subset_iff {P : set (α × β)} :
id └─┘ ┴ ┴ ┴
src └─┘ ┴
typ └─┘ ┴ ┴ ┴
1420 (set.prod s t ⊆ P) ↔ ∀ (x ∈ s) (y ∈ t), (x, y) ∈ P :=
id └──────┘ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src └──────┘ ┴ ┴ ┴ ┴
typ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
doc └──────┘
1421 ⟨λ h _ xin _ yin, h (mk_mem_prod xin yin),
id ┴ ┴ └─┘ ┴ └─┘ ┴ └─────────┘ └─┘ └─┘
src └─────────┘
typ ┴ ┴ └─┘ ┴ └─┘ ┴ └─────────┘ └─┘ └─┘
1422 λ h _ pin, by { cases mem_prod.1 pin with hs ht, simpa using h _ hs _ ht }⟩
id ┴ ┴ └─┘ └──────┘ └─┘ ┴ └┘ └┘
src └────┘└──────┘└─┘ └─────────┘ └──────────┘ └─┘ └─┘ ┴
typ ┴ ┴ └─┘ └────┘└──────┘└─┘└─┘└─────────┘ └──────────┘┴└─┘└┘└─┘└┘┴
doc └────┘ └─┘ └─────────┘ └──────────┘ └─┘ └─┘ ┴
txt └────┘ └─┘ └─────────┘ └──────────┘ └─┘ └─┘ ┴
par └────┘ └─┘ └─────────┘ └──────────┘ └─┘ └─┘ ┴
pid ┴ └─┘ └─────────┘ ┴└────┘ └─┘ └─┘ ┴
st └────────────────────────────────┘└────────────────────────┘└┘
1423
1424 @[simp] theorem prod_empty : set.prod s ∅ = (∅ : set (α × β)) :=
id └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
src └──────┘ ┴ ┴ ┴ └─┘ ┴
typ └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
doc └──┘ └──────┘
1425 ext $ by simp [set.prod]
id └─┘ └──────┘
src └─┘ └────┘└──────┘└─
typ └─┘ └────┘└──────┘└─
doc └────┘└──────┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └────────────────
1426
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1427 @[simp] theorem empty_prod : set.prod ∅ t = (∅ : set (α × β)) :=
id └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
src └──────┘ ┴ ┴ ┴ └─┘ ┴
typ └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
doc └──┘ └──────┘
1428 ext $ by simp [set.prod]
id └─┘ └──────┘
src └─┘ └────┘└──────┘└─
typ └─┘ └────┘└──────┘└─
doc └────┘└──────┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └────────────────
1429
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1430 theorem insert_prod {a : α} {s : set α} {t : set β} :
id ┴ └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ ┴ └─┘ ┴ └─┘ ┴
1431 set.prod (insert a s) t = (prod.mk a '' t) ∪ set.prod s t :=
id └──────┘ └────┘ ┴ ┴ ┴ ┴ └─────┘ ┴ └┘ ┴ ┴ └──────┘ ┴ ┴
src └──────┘ └────┘ ┴ └─────┘ └┘ ┴ └──────┘
typ └──────┘ └────┘ ┴ ┴ ┴ ┴ └─────┘ ┴ └┘ ┴ ┴ └──────┘ ┴ ┴
doc └──────┘ └──────┘
1432 ext begin simp [set.prod, image, iff_def, or_imp_distrib] {contextual := tt}; cc end
id └─┘ └──────┘ └───┘ └─────┘ └────────────┘ └┘
src └─┘ └────┘└──────┘└┘└───┘└┘└─────┘└┘└────────────┘└┘ └────────────┘└┘┴ └─┘
typ └─┘ └────┘└──────┘└┘└───┘└┘└─────┘└┘└────────────┘└┘ └────────────┘└┘┴ └─┘
doc └────┘└──────┘└┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
txt └────┘ └┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
par └────┘ └┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
pid ┴┴ └┘ └┘ └┘ ┴┴ └────────────┘ ┴ ┴
st └───────────────────────────────────────────────────────────────────────────┘└─┘
1433
1434 theorem prod_insert {b : β} {s : set α} {t : set β} :
id ┴ └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ ┴ └─┘ ┴ └─┘ ┴
1435 set.prod s (insert b t) = ((λa, (a, b)) '' s) ∪ set.prod s t :=
id └──────┘ ┴ └────┘ ┴ ┴ ┴ ┴ ┴┴ ┴ └┘ ┴ ┴ └──────┘ ┴ ┴
src └──────┘ └────┘ ┴ ┴ └┘ ┴ └──────┘
typ └──────┘ ┴ └────┘ ┴ ┴ ┴ ┴ ┴┴ ┴ └┘ ┴ ┴ └──────┘ ┴ ┴
doc └──────┘ └──────┘
1436 ext begin simp [set.prod, image, iff_def, or_imp_distrib] {contextual := tt}; cc end
id └─┘ └──────┘ └───┘ └─────┘ └────────────┘ └┘
src └─┘ └────┘└──────┘└┘└───┘└┘└─────┘└┘└────────────┘└┘ └────────────┘└┘┴ └─┘
typ └─┘ └────┘└──────┘└┘└───┘└┘└─────┘└┘└────────────┘└┘ └────────────┘└┘┴ └─┘
doc └────┘└──────┘└┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
txt └────┘ └┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
par └────┘ └┘ └┘ └┘ └┘ └────────────┘ ┴ └─┘
pid ┴┴ └┘ └┘ └┘ ┴┴ └────────────┘ ┴ ┴
st └───────────────────────────────────────────────────────────────────────────┘└─┘
1437
1438 theorem prod_preimage_eq {f : γ → α} {g : δ → β} :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1439 set.prod (preimage f s) (preimage g t) = preimage (λp, (f p.1, g p.2)) (set.prod s t) := rfl
id └──────┘ └──────┘ ┴ ┴ └──────┘ ┴ ┴ ┴ └──────┘ ┴ ┴┴ ┴┴ ┴ ┴┴ └──────┘ ┴ ┴ └─┘
src └──────┘ └──────┘ └──────┘ ┴ └──────┘ ┴ ┴ ┴ └──────┘ └─┘
typ └──────┘ └──────┘ ┴ ┴ └──────┘ ┴ ┴ ┴ └──────┘ ┴ ┴┴ ┴┴ ┴ ┴┴ └──────┘ ┴ ┴ └─┘
doc └──────┘ └──────┘ └──────┘ └──────┘ └──────┘
1440
1441 theorem prod_mono {s₁ s₂ : set α} {t₁ t₂ : set β} (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) :
id └─┘ ┴ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘
src └─┘ └─┘ ┴ ┴
typ └─┘ ┴ └─┘ ┴ └┘ ┴ └┘ └┘ ┴ └┘
1442 set.prod s₁ t₁ ⊆ set.prod s₂ t₂ :=
id └──────┘ └┘ └┘ ┴ └──────┘ └┘ └┘
src └──────┘ ┴ └──────┘
typ └──────┘ └┘ └┘ ┴ └──────┘ └┘ └┘
doc └──────┘ └──────┘
1443 assume x ⟨h₁, h₂⟩, ⟨hs h₁, ht h₂⟩
id ┴ ┴└┘ └┘ └┘ └┘
typ ┴ ┴└┘ └┘ └┘ └┘
1444
1445 theorem prod_inter_prod : set.prod s₁ t₁ ∩ set.prod s₂ t₂ = set.prod (s₁ ∩ s₂) (t₁ ∩ t₂) :=
id └──────┘ └┘ └┘ ┴ └──────┘ └┘ └┘ ┴ └──────┘ └┘ ┴ └┘ └┘ ┴ └┘
src └──────┘ ┴ └──────┘ ┴ └──────┘ ┴ ┴
typ └──────┘ └┘ └┘ ┴ └──────┘ └┘ └┘ ┴ └──────┘ └┘ ┴ └┘ └┘ ┴ └┘
doc └──────┘ └──────┘ └──────┘
1446 subset.antisymm
id └─────────────┘
src └─────────────┘
typ └─────────────┘
1447 (assume ⟨a, b⟩ ⟨⟨ha₁, hb₁⟩, ⟨ha₂, hb₂⟩⟩, ⟨⟨ha₁, ha₂⟩, ⟨hb₁, hb₂⟩⟩)
id ┴ ┴ └─┘ └─┘ └─┘ └─┘
typ ┴ ┴ └─┘ └─┘ └─┘ └─┘
1448 (subset_inter
id └──────────┘
src └──────────┘
typ └──────────┘
1449 (prod_mono (inter_subset_left _ _) (inter_subset_left _ _))
id └───────┘ └───────────────┘ └───────────────┘
src └───────┘ └───────────────┘ └───────────────┘
typ └───────┘ └───────────────┘ └───────────────┘
1450 (prod_mono (inter_subset_right _ _) (inter_subset_right _ _)))
id └───────┘ └────────────────┘ └────────────────┘
src └───────┘ └────────────────┘ └────────────────┘
typ └───────┘ └────────────────┘ └────────────────┘
1451
1452 theorem image_swap_prod : (λp:β×α, (p.2, p.1)) '' set.prod t s = set.prod s t :=
id ┴┴┴ ┴┴┴ ┴┴ └┘ └──────┘ ┴ ┴ ┴ └──────┘ ┴ ┴
src ┴ ┴ ┴ ┴ └┘ └──────┘ ┴ └──────┘
typ ┴┴┴ ┴┴┴ ┴┴ └┘ └──────┘ ┴ ┴ ┴ └──────┘ ┴ ┴
doc └──────┘ └──────┘
1453 ext $ assume ⟨a, b⟩, by simp [mem_image_eq, set.prod, and_comm]; exact
id └─┘ ┴ └──────────┘ └──────┘ └──────┘
src └─┘ └────┘└──────────┘└┘└──────┘└┘└──────┘┴ └────┘
typ └─┘ ┴ └────┘└──────────┘└┘└──────┘└┘└──────┘┴ └────┘
doc └────┘ └┘└──────┘└┘ ┴ └────┘
txt └────┘ └┘ └┘ ┴ └────┘
par └────┘ └┘ └┘ ┴ └────┘
pid ┴┴ └┘ └┘ ┴ ┴
st └───────────────────────────────────────────────
1454 ⟨ assume ⟨b', a', ⟨h_a, h_b⟩, h⟩, by subst a'; subst b'; assumption,
id └┘ └┘
src ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ ┴└────┘ └┘└────┘ └┘└────────┘└─
typ ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ └─────┘└┘└──────┘└┘└┘└────────┘└─
doc ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ ┴└────┘ └┘└────┘ └┘└────────┘└─
txt ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ ┴└────┘ └┘└────┘ └┘└────────┘└─
par ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ └─────┘ └──────┘ └┘└────────┘└─
pid ┴ └┘ └┘ └┘ └┘ └─┘ └─┘ └─────┘ └──────┘ └─────────────
st ───────────────────────────────────┘└─────────────────────────────┘└─
1455 assume h, ⟨b, a, ⟨rfl, rfl⟩, h⟩⟩
id ┴ ┴ └─┘
src ─┘ └──┘ └┘ └┘ └┘└─┘└─┘ └──
typ ─┘ └──┘ ┴└┘┴└┘ └┘└─┘└─┘ └──
doc ─┘ └──┘ └┘ └┘ └┘ └─┘ └──
txt ─┘ └──┘ └┘ └┘ └┘ └─┘ └──
par ─┘ └──┘ └┘ └┘ └┘ └─┘ └──
pid ─┘ └──┘ └┘ └┘ └┘ └─┘ └┘└
st ───────────────────────────────────
1456
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1457 theorem image_swap_eq_preimage_swap : image (@prod.swap α β) = preimage prod.swap :=
id └───┘ └───────┘ ┴ ┴ ┴ └──────┘ └───────┘
src └───┘ └───────┘ ┴ └──────┘ └───────┘
typ └───┘ └───────┘ ┴ ┴ ┴ └──────┘ └───────┘
doc └───────┘ └──────┘ └───────┘
1458 image_eq_preimage_of_inverse prod.swap_left_inverse prod.swap_right_inverse
id └──────────────────────────┘ └────────────────────┘ └─────────────────────┘
src └──────────────────────────┘ └────────────────────┘ └─────────────────────┘
typ └──────────────────────────┘ └────────────────────┘ └─────────────────────┘
1459
1460 theorem prod_image_image_eq {m₁ : α → γ} {m₂ : β → δ} :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1461 set.prod (image m₁ s) (image m₂ t) = image (λp:α×β, (m₁ p.1, m₂ p.2)) (set.prod s t) :=
id └──────┘ └───┘ └┘ ┴ └───┘ └┘ ┴ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ └┘ ┴┴ └──────┘ ┴ ┴
src └──────┘ └───┘ └───┘ ┴ └───┘ ┴ ┴ ┴ ┴ └──────┘
typ └──────┘ └───┘ └┘ ┴ └───┘ └┘ ┴ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ └┘ ┴┴ └──────┘ ┴ ┴
doc └──────┘ └──────┘
1462 ext $ by simp [-exists_and_distrib_right, exists_and_distrib_right.symm, and.left_comm, and.assoc, and.comm]
id └─┘ └───────────┘ └───────┘ └──────┘
src └─┘ └───────────────────────────────┘ └┘└───────────┘└┘└───────┘└┘└──────┘└─
typ └─┘ └───────────────────────────────┘└───────────────────────────┘└┘└───────────┘└┘└───────┘└┘└──────┘└─
doc └───────────────────────────────┘ └┘ └┘ └┘ └─
txt └───────────────────────────────┘ └┘ └┘ └┘ └─
par └───────────────────────────────┘ └┘ └┘ └┘ └─
pid ┴└──────────────────────────┘ └┘ └┘ └┘ ┴└
st └────────────────────────────────────────────────────────────────────────────────────────────────────
1463
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1464 theorem prod_range_range_eq {α β γ δ} {m₁ : α → γ} {m₂ : β → δ} :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1465 set.prod (range m₁) (range m₂) = range (λp:α×β, (m₁ p.1, m₂ p.2)) :=
id └──────┘ └───┘ └┘ └───┘ └┘ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ └┘ ┴┴
src └──────┘ └───┘ └───┘ ┴ └───┘ ┴ ┴ ┴ ┴
typ └──────┘ └───┘ └┘ └───┘ └┘ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ └┘ ┴┴
doc └──────┘ └───┘ └───┘ └───┘
1466 ext $ by simp [range]
id └─┘ └───┘
src └─┘ └────┘└───┘└─
typ └─┘ └────┘└───┘└─
doc └────┘└───┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └─────────────
1467
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1468 theorem prod_range_univ_eq {α β γ} {m₁ : α → γ} :
id ┴ ┴
typ ┴ ┴
1469 set.prod (range m₁) (univ : set β) = range (λp:α×β, (m₁ p.1, p.2)) :=
id └──────┘ └───┘ └┘ └──┘ └─┘ ┴ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ ┴┴
src └──────┘ └───┘ └──┘ └─┘ ┴ └───┘ ┴ ┴ ┴ ┴
typ └──────┘ └───┘ └┘ └──┘ └─┘ ┴ ┴ └───┘ ┴┴┴ ┴└┘ ┴┴ ┴┴
doc └──────┘ └───┘ └───┘
1470 ext $ by simp [range]
id └─┘ └───┘
src └─┘ └────┘└───┘└─
typ └─┘ └────┘└───┘└─
doc └────┘└───┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └─────────────
1471
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1472 theorem prod_univ_range_eq {α β δ} {m₂ : β → δ} :
id ┴ ┴
typ ┴ ┴
1473 set.prod (univ : set α) (range m₂) = range (λp:α×β, (p.1, m₂ p.2)) :=
id └──────┘ └──┘ └─┘ ┴ └───┘ └┘ ┴ └───┘ ┴┴┴ ┴┴┴ └┘ ┴┴
src └──────┘ └──┘ └─┘ └───┘ ┴ └───┘ ┴ ┴ ┴ ┴
typ └──────┘ └──┘ └─┘ ┴ └───┘ └┘ ┴ └───┘ ┴┴┴ ┴┴┴ └┘ ┴┴
doc └──────┘ └───┘ └───┘
1474 ext $ by simp [range]
id └─┘ └───┘
src └─┘ └────┘└───┘└─
typ └─┘ └────┘└───┘└─
doc └────┘└───┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └─────────────
1475
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1476 @[simp] theorem prod_singleton_singleton {a : α} {b : β} :
id ┴ ┴
typ ┴ ┴
doc └──┘
1477 set.prod {a} {b} = ({(a, b)} : set (α×β)) :=
id └──────┘ ┴┴ ┴┴ ┴ ┴┴┴ ┴ └─┘ ┴┴┴
src └──────┘ ┴ ┴ ┴ ┴┴ └─┘ ┴
typ └──────┘ ┴┴ ┴┴ ┴ ┴┴┴ ┴ └─┘ ┴┴┴
doc └──────┘
1478 ext $ by simp [set.prod]
id └─┘ └──────┘
src └─┘ └────┘└──────┘└─
typ └─┘ └────┘└──────┘└─
doc └────┘└──────┘└─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └────────────────
1479
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1480 theorem nonempty.prod : s.nonempty → t.nonempty → (s.prod t).nonempty
id ┴└───────┘ ┴ ┴└───────┘ ┴└───┘ ┴ └──────┘
src └───────┘ └───────┘ └───┘ └──────┘
typ ┴└───────┘ ┴ ┴└───────┘ ┴└───┘ ┴ └──────┘
doc └───────┘ └───────┘ └───┘ └──────┘
1481 | ⟨x, hx⟩ ⟨y, hy⟩ := ⟨(x, y), ⟨hx, hy⟩⟩
id ┴ └┘ ┴ └┘ ┴
src ┴
typ ┴ └┘ ┴ └┘ ┴
1482
1483 theorem nonempty.fst : (s.prod t).nonempty → s.nonempty
id ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘
src └───┘ └──────┘ └───────┘
typ ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘
doc └───┘ └──────┘ └───────┘
1484 | ⟨p, hp⟩ := ⟨p.1, hp.1⟩
id ┴ └┘ ┴ ┴
src ┴ ┴
typ ┴ └┘ ┴ ┴
1485
1486 theorem nonempty.snd : (s.prod t).nonempty → t.nonempty
id ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘
src └───┘ └──────┘ └───────┘
typ ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘
doc └───┘ └──────┘ └───────┘
1487 | ⟨p, hp⟩ := ⟨p.2, hp.2⟩
id ┴ └┘ ┴ ┴
src ┴ ┴
typ ┴ └┘ ┴ ┴
1488
1489 theorem prod_nonempty_iff : (s.prod t).nonempty ↔ s.nonempty ∧ t.nonempty :=
id ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘ ┴ ┴└───────┘
src └───┘ └──────┘ ┴ └───────┘ ┴ └───────┘
typ ┴└───┘ ┴ └──────┘ ┴ ┴└───────┘ ┴ ┴└───────┘
doc └───┘ └──────┘ └───────┘ └───────┘
1490 ⟨λ h, ⟨h.fst, h.snd⟩, λ h, nonempty.prod h.1 h.2⟩
id ┴ ┴└──┘ ┴└──┘ ┴ └───────────┘ ┴┴ ┴┴
src └──┘ └──┘ └───────────┘ ┴ ┴
typ ┴ ┴└──┘ ┴└──┘ ┴ └───────────┘ ┴┴ ┴┴
1491
1492 theorem prod_eq_empty_iff {s : set α} {t : set β} :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1493 set.prod s t = ∅ ↔ (s = ∅ ∨ t = ∅) :=
id └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──────┘
1494 by simp only [not_nonempty_iff_eq_empty.symm, prod_nonempty_iff, classical.not_and_distrib]
id └───────────────┘ └───────────────────────┘
src └─────────┘ └┘└───────────────┘└┘└───────────────────────┘└─
typ └─────────┘└────────────────────────────┘└┘└───────────────┘└┘└───────────────────────┘└─
doc └─────────┘ └┘ └┘ └─
txt └─────────┘ └┘ └┘ └─
par └─────────┘ └┘ └┘ └─
pid ┴└──┘└┘ └┘ └┘ ┴└
st └─────────────────────────────────────────────────────────────────────────────────────────
1495
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1496 @[simp] theorem prod_mk_mem_set_prod_eq {a : α} {b : β} {s : set α} {t : set β} :
id ┴ ┴ └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ ┴ ┴ └─┘ ┴ └─┘ ┴
doc └──┘
1497 (a, b) ∈ set.prod s t = (a ∈ s ∧ b ∈ t) := rfl
id ┴┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
src ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ └─┘
typ ┴┴ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
doc └──────┘
1498
1499 @[simp] theorem univ_prod_univ : set.prod (@univ α) (@univ β) = univ :=
id └──────┘ └──┘ ┴ └──┘ ┴ ┴ └──┘
src └──────┘ └──┘ └──┘ ┴ └──┘
typ └──────┘ └──┘ ┴ └──┘ ┴ ┴ └──┘
doc └──┘ └──────┘
1500 ext $ assume ⟨a, b⟩, by simp
id └─┘ ┴
src └─┘ └────
typ └─┘ ┴ └────
doc └────
txt └────
par └────
pid └
st └─────
1501
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1502 lemma prod_sub_preimage_iff {W : set γ} {f : α × β → γ} :
id └─┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴
1503 set.prod s t ⊆ f ⁻¹' W ↔ ∀ a b, a ∈ s → b ∈ t → f (a, b) ∈ W :=
id └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
src └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
typ └──────┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴
doc └──────┘ └─┘
1504 by simp [subset_def]
id └────────┘
src └────┘└────────┘└─
typ └────┘└────────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └──────────────────
1505
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1506 lemma fst_image_prod_subset (s : set α) (t : set β) :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1507 prod.fst '' (set.prod s t) ⊆ s :=
id └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
src └──────┘ └┘ └──────┘ ┴
typ └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
doc └──────┘
1508 λ _ h, let ⟨_, ⟨h₂, _⟩, h₁⟩ := (set.mem_image _ _ _).1 h in h₁ ▸ h₂
id ┴ ┴ └─┘ └┘ └┘ └───────────┘ ┴ ┴ ┴
src └───────────┘ ┴ ┴
typ ┴ ┴ └─┘ └┘ └┘ └───────────┘ ┴ ┴ ┴
1509
1510 lemma prod_subset_preimage_fst (s : set α) (t : set β) :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1511 set.prod s t ⊆ prod.fst ⁻¹' s :=
id └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴
src └──────┘ ┴ └──────┘ └─┘
typ └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴
doc └──────┘ └─┘
1512 image_subset_iff.1 (fst_image_prod_subset s t)
id └──────────────┘┴ └───────────────────┘ ┴ ┴
src └──────────────┘┴ └───────────────────┘
typ └──────────────┘┴ └───────────────────┘ ┴ ┴
doc └──────────────┘
1513
1514 lemma fst_image_prod (s : set β) {t : set α} (ht : t.nonempty) :
id └─┘ ┴ └─┘ ┴ ┴└───────┘
src └─┘ └─┘ └───────┘
typ └─┘ ┴ └─┘ ┴ ┴└───────┘
doc └───────┘
1515 prod.fst '' (set.prod s t) = s :=
id └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
src └──────┘ └┘ └──────┘ ┴
typ └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
doc └──────┘
1516 set.subset.antisymm (fst_image_prod_subset _ _)
id └─────────────────┘ └───────────────────┘
src └─────────────────┘ └───────────────────┘
typ └─────────────────┘ └───────────────────┘
1517 $ λ y y_in, let ⟨x, x_in⟩ := ht in
id ┴ └──┘ └─┘ ┴ └──┘ └┘
typ ┴ └──┘ └─┘ ┴ └──┘ └┘
1518 ⟨(y, x), ⟨y_in, x_in⟩, rfl⟩
id ┴┴ └──┘ └─┘
src ┴ └─┘
typ ┴┴ └──┘ └─┘
1519
1520 lemma snd_image_prod_subset (s : set α) (t : set β) :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1521 prod.snd '' (set.prod s t) ⊆ t :=
id └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
src └──────┘ └┘ └──────┘ ┴
typ └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
doc └──────┘
1522 λ _ h, let ⟨_, ⟨_, h₂⟩, h₁⟩ := (set.mem_image _ _ _).1 h in h₁ ▸ h₂
id ┴ ┴ └─┘ └┘ └┘ └───────────┘ ┴ ┴ ┴
src └───────────┘ ┴ ┴
typ ┴ ┴ └─┘ └┘ └┘ └───────────┘ ┴ ┴ ┴
1523
1524 lemma prod_subset_preimage_snd (s : set α) (t : set β) :
id └─┘ ┴ └─┘ ┴
src └─┘ └─┘
typ └─┘ ┴ └─┘ ┴
1525 set.prod s t ⊆ prod.snd ⁻¹' t :=
id └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴
src └──────┘ ┴ └──────┘ └─┘
typ └──────┘ ┴ ┴ ┴ └──────┘ └─┘ ┴
doc └──────┘ └─┘
1526 image_subset_iff.1 (snd_image_prod_subset s t)
id └──────────────┘┴ └───────────────────┘ ┴ ┴
src └──────────────┘┴ └───────────────────┘
typ └──────────────┘┴ └───────────────────┘ ┴ ┴
doc └──────────────┘
1527
1528 lemma snd_image_prod {s : set α} (hs : s.nonempty) (t : set β) :
id └─┘ ┴ ┴└───────┘ └─┘ ┴
src └─┘ └───────┘ └─┘
typ └─┘ ┴ ┴└───────┘ └─┘ ┴
doc └───────┘
1529 prod.snd '' (set.prod s t) = t :=
id └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
src └──────┘ └┘ └──────┘ ┴
typ └──────┘ └┘ └──────┘ ┴ ┴ ┴ ┴
doc └──────┘
1530 set.subset.antisymm (snd_image_prod_subset _ _)
id └─────────────────┘ └───────────────────┘
src └─────────────────┘ └───────────────────┘
typ └─────────────────┘ └───────────────────┘
1531 $ λ y y_in, let ⟨x, x_in⟩ := hs in
id ┴ └──┘ └─┘ ┴ └──┘ └┘
typ ┴ └──┘ └─┘ ┴ └──┘ └┘
1532 ⟨(x, y), ⟨x_in, y_in⟩, rfl⟩
id ┴ ┴ └──┘ └─┘
src ┴ └─┘
typ ┴ ┴ └──┘ └─┘
1533
1534 /-- A product set is included in a product set if and only factors are included, or a factor of the
1535 first set is empty. -/
1536 lemma prod_subset_prod_iff :
1537 (set.prod s t ⊆ set.prod s₁ t₁) ↔ (s ⊆ s₁ ∧ t ⊆ t₁) ∨ (s = ∅) ∨ (t = ∅) :=
id └──────┘ ┴ ┴ ┴ └──────┘ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └──────┘ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ └──────┘ ┴ ┴ ┴ └──────┘ └┘ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──────┘ └──────┘
1538 begin
st └─────
1539 classical,
src └───────┘
typ └───────┘
doc └───────┘
txt └───────┘
par └───────┘
st ──────────┘└─
1540 cases (set.prod s t).eq_empty_or_nonempty with h h,
id └──────┘ ┴ ┴
src └────┘ └──────┘┴ ┴ └─────────────────────────────┘
typ └────┘ └──────┘┴┴┴┴└─────────────────────────────┘
doc └────┘ └──────┘┴ ┴ └─────────────────────────────┘
txt └────┘ ┴ ┴ └─────────────────────────────┘
par └────┘ ┴ ┴ └─────────────────────────────┘
pid ┴ ┴ ┴ └───────────────────┘└────────┘
st ───────────────────────────────────────────────────┘└─
1541 { simp [h, prod_eq_empty_iff.1 h] },
id ┴ └───────────────┘ ┴
src └────┘ └┘└───────────────┘└─┘ └┘
typ └────┘┴└┘└───────────────┘└─┘┴└┘
doc └────┘ └┘ └─┘ └┘
txt └────┘ └┘ └─┘ └┘
par └────┘ └┘ └─┘ └┘
pid ┴┴ └┘ └─┘ ┴┴
st ───┘└──────────────────────────────┘└┘└
1542 { have st : s.nonempty ∧ t.nonempty, by rwa [prod_nonempty_iff] at h,
id └────────┘ └────────┘ └───────────────┘
src └────────┘└────────┘┴ ┴└────────┘ └───┘└───────────────┘└────┘
typ └────────┘└────────┘┴ ┴└────────┘ └───┘└───────────────┘└────┘
doc └────────┘└────────┘┴ ┴└────────┘ └───┘ └────┘
txt └────────┘ ┴ ┴ └───┘ └────┘
par └────────┘ ┴ ┴ └───┘ └────┘
pid └─────┘└─┘ ┴ ┴ └┘ ┴└───┘
st ────────────────────────────────────┘ └───────────────┘┴ └─
1543 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ────────┘└─
1544 { assume H : set.prod s t ⊆ set.prod s₁ t₁,
id ┴ ┴ ┴ └──────┘ └┘ └┘
src └─────────┘ ┴ ┴ ┴┴┴└──────┘┴ ┴
typ └─────────┘ ┴┴┴┴┴┴┴└──────┘┴└┘┴└┘
doc └─────────┘ ┴ ┴ ┴ ┴└──────┘┴ ┴
txt └─────────┘ ┴ ┴ ┴ ┴ ┴ ┴
par └─────────┘ ┴ ┴ ┴ ┴ ┴ ┴
pid └─────────┘ ┴ ┴ ┴ ┴ ┴ ┴
st ─────┘└──────────────────────────────────────┘└─
1545 have h' : s₁.nonempty ∧ t₁.nonempty := prod_nonempty_iff.1 (h.mono H),
id └─────────┘ └─────────┘ └───────────────┘ └────┘ ┴
src └────────┘└─────────┘┴ ┴└─────────┘└──┘└───────────────┘└─┘ └────┘┴ ┴
typ └────────┘└─────────┘┴ ┴└─────────┘└──┘└───────────────┘└─┘ └────┘┴┴┴
doc └────────┘└─────────┘┴ ┴└─────────┘└──┘ └─┘ ┴ ┴
txt └────────┘ ┴ ┴ └──┘ └─┘ ┴ ┴
par └────────┘ ┴ ┴ └──┘ └─┘ ┴ ┴
pid └─────┘└─┘ ┴ ┴ └──┘ └─┘ ┴ ┴
st ──────────────────────────────────────────────────────────────────────────┘└─
1546 refine or.inl ⟨_, _⟩,
id └────┘
src └─────┘└────┘┴ └───┘
typ └─────┘└────┘┴ └───┘
doc └─────┘ ┴ └───┘
txt └─────┘ ┴ └───┘
par └─────┘ ┴ └───┘
pid ┴ ┴ └───┘
st ─────────────────────────┘└─
1547 show s ⊆ s₁,
id ┴ └┘
src └───┘ ┴ ┴
typ └───┘┴┴ ┴└┘
doc └───┘ ┴ ┴
txt └───┘ ┴ ┴
par └───┘ ┴ ┴
pid └───┘ ┴ ┴
st ───────────────────
1548 { have := image_subset (prod.fst : α × β → α) H,
id └──────────┘ └──────┘ ┴ ┴ ┴ ┴
src └──────┘└──────────┘┴ └──────┘└─┘ ┴┴┴ ┴ ┴ └┘
typ └──────┘└──────────┘┴ └──────┘└─┘ ┴┴┴┴┴ ┴┴└┘┴
doc └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
txt └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
par └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
pid └───┘└─┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
st ───────┘└───────────────────────────────────────────┘└─
1549 rwa [fst_image_prod _ st.2, fst_image_prod _ h'.2] at this },
id └────────────┘ └┘ └────────────┘ └┘
src └───┘└────────────┘└─┘ └──┘└────────────┘└─┘ └──────────┘
typ └───┘└────────────┘└─┘└┘└──┘└────────────┘└─┘└┘└──────────┘
doc └───┘ └─┘ └──┘ └─┘ └──────────┘
txt └───┘ └─┘ └──┘ └─┘ └──────────┘
par └───┘ └─┘ └──┘ └─┘ └──────────┘
pid └┘ └─┘ └──┘ └─┘ └─┘└──────┘┴
st ───────────────────────────────┘└─────────────────────┘└─┘└───────┘└┘└
1550 show t ⊆ t₁,
id ┴ └┘
src └───┘ ┴ ┴
typ └───┘┴┴ ┴└┘
doc └───┘ ┴ ┴
txt └───┘ ┴ ┴
par └───┘ ┴ ┴
pid └───┘ ┴ ┴
st ───────────────────
1551 { have := image_subset (prod.snd : α × β → β) H,
id └──────────┘ └──────┘ ┴ ┴ ┴
src └──────┘└──────────┘┴ └──────┘└─┘ ┴ ┴ ┴ ┴ └┘
typ └──────┘└──────────┘┴ └──────┘└─┘┴┴ ┴ ┴ ┴┴└┘┴
doc └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
txt └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
par └──────┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
pid └───┘└─┘ ┴ └─┘ ┴ ┴ ┴ ┴ └┘
st ────────────────────────────────────────────────────┘└─
1552 rwa [snd_image_prod st.1, snd_image_prod h'.1] at this } },
id └────────────┘ └┘ └────────────┘ └┘
src └───┘└────────────┘┴ └──┘└────────────┘┴ └──────────┘
typ └───┘└────────────┘┴└┘└──┘└────────────┘┴└┘└──────────┘
doc └───┘ ┴ └──┘ ┴ └──────────┘
txt └───┘ ┴ └──┘ ┴ └──────────┘
par └───┘ ┴ └──┘ ┴ └──────────┘
pid └┘ ┴ └──┘ ┴ └─┘└──────┘┴
st ─────────────────────────────┘└───────────────────┘└─┘└───────┘└──┘└
1553 { assume H,
src └──────┘
typ └──────┘
doc └──────┘
txt └──────┘
par └──────┘
pid └──────┘
st ─────────────┘└─
1554 simp only [st.1.ne_empty, st.2.ne_empty, or_false] at H,
id └┘ └┘ └──────┘
src └─────────┘ └───────────┘ └───────────┘└──────┘└────┘
typ └─────────┘└┘└───────────┘└┘└───────────┘└──────┘└────┘
doc └─────────┘ └───────────┘ └───────────┘ └────┘
txt └─────────┘ └───────────┘ └───────────┘ └────┘
par └─────────┘ └───────────┘ └───────────┘ └────┘
pid ┴└──┘└┘ └───────────┘ └───────────┘ ┴┴└──┘
st ────────────────────────────────────────────────────────────┘└─
1555 exact prod_mono H.1 H.2 } }
id └───────┘ ┴
src └────┘└───────┘┴ └─┘ └─┘
typ └────┘└───────┘┴ └─┘┴└─┘
doc └────┘ ┴ └─┘ └─┘
txt └────┘ ┴ └─┘ └─┘
par └────┘ ┴ └─┘ └─┘
pid ┴ ┴ └─┘ └─┘
st ─────────────────────────────┘└───
1556 end
st ──┘
1557
1558 end prod
1559
1560 section pi
1561 variables {α : Type*} {π : α → Type*}
1562
1563 /-- Given an index set `i` and a family of sets `s : Πa, set (π a)`, `pi i s`
1564 is the set of dependent functions `f : Πa, π a` such that `f a` belongs to `π a`
1565 whenever `a ∈ i`. -/
1566 def pi (i : set α) (s : Πa, set (π a)) : set (Πa, π a) := { f | ∀a∈i, f a ∈ s a }
id └─┘ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ └─┘ └─┘ ┴ ┴
typ └─┘ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1567
1568 @[simp] lemma pi_empty_index (s : Πa, set (π a)) : pi ∅ s = univ := by ext; simp [pi]
id ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ └──┘ └┘
src └─┘ └┘ ┴ ┴ └──┘ └─┘ └────┘└┘└─
typ ┴ └─┘ ┴ ┴ └┘ ┴ ┴ ┴ └──┘ └─┘ └────┘└┘└─
doc └──┘ └┘ └─┘ └────┘└┘└─
txt └─┘ └────┘ └─
par └─┘ └────┘ └─
pid ┴┴ ┴└
st └───────────────
1569
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1570 @[simp] lemma pi_insert_index (a : α) (i : set α) (s : Πa, set (π a)) :
id ┴ └─┘ ┴ ┴ └─┘ ┴ ┴
src └─┘ └─┘
typ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴
doc └──┘
1571 pi (insert a i) s = ((λf, f a) ⁻¹' s a) ∩ pi i s :=
id └┘ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴ ┴
src └┘ └────┘ ┴ └─┘ ┴ └┘
typ └┘ └────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └┘ ┴ ┴
doc └┘ └─┘ └┘
1572 by ext; simp [pi, or_imp_distrib, forall_and_distrib]
id └┘ └────────────┘ └────────────────┘
src └─┘ └────┘└┘└┘└────────────┘└┘└────────────────┘└─
typ └─┘ └────┘└┘└┘└────────────┘└┘└────────────────┘└─
doc └─┘ └────┘└┘└┘ └┘ └─
txt └─┘ └────┘ └┘ └┘ └─
par └─┘ └────┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ ┴└
st └───────────────────────────────────────────────────
1573
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1574 @[simp] lemma pi_singleton_index (a : α) (s : Πa, set (π a)) :
id ┴ ┴ └─┘ ┴ ┴
src └─┘
typ ┴ ┴ └─┘ ┴ ┴
doc └──┘
1575 pi {a} s = ((λf:(Πa, π a), f a) ⁻¹' s a) :=
id └┘ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
src └┘ ┴ ┴ └─┘
typ └┘ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
doc └┘ └─┘
1576 by ext; simp [pi]
id └┘
src └─┘ └────┘└┘└─
typ └─┘ └────┘└┘└─
doc └─┘ └────┘└┘└─
txt └─┘ └────┘ └─
par └─┘ └────┘ └─
pid ┴┴ ┴└
st └───────────────
1577
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1578 lemma pi_if {p : α → Prop} [h : decidable_pred p] (i : set α) (s t : Πa, set (π a)) :
id ┴ └────────────┘ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴
src └────────────┘ └─┘ └─┘
typ ┴ └────────────┘ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴
1579 pi i (λa, if p a then s a else t a) = pi {a ∈ i | p a} s ∩ pi {a ∈ i | ¬ p a} t :=
id └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴
src └┘ ┴ └┘ ┴ ┴ └┘ ┴ ┴
typ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴
doc └┘ └┘ └┘
1580 begin
st └─────
1581 ext f,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
pid └┘
st ──────┘└─
1582 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
1583 { assume h, split; { rintros a ⟨hai, hpa⟩, simpa [*] using h a } },
id ┴ ┴
src └──────┘ └───┘ └──────────────────┘ └──────────────┘ ┴ ┴
typ └──────┘ └───┘ └──────────────────┘ └──────────────┘┴┴┴┴
doc └──────┘ └───┘ └──────────────────┘ └──────────────┘ ┴ ┴
txt └──────┘ └───┘ └──────────────────┘ └──────────────┘ ┴ ┴
par └──────┘ └───┘ └──────────────────┘ └──────────────┘ ┴ ┴
pid └──────┘ └───────────┘ ┴└─┘┴└────┘ ┴ ┴
st ───┘└──────┘└───────┘└────────────────────┘└────────────────────┘└──┘└
1584 { rintros ⟨hs, ht⟩ a hai,
src └────────────────────┘
typ └────────────────────┘
doc └────────────────────┘
txt └────────────────────┘
par └────────────────────┘
pid └─────────────┘
st ─────────────────────────┘└─
1585 by_cases p a; simp [*, pi] at * }
id ┴ ┴ └┘
src └───────┘ ┴ └───────┘└┘└─────┘
typ └───────┘┴┴┴ └───────┘└┘└─────┘
doc └───────┘ ┴ └───────┘└┘└─────┘
txt └───────┘ ┴ └───────┘ └─────┘
par └───────┘ ┴ └───────┘ └─────┘
pid ┴ ┴ ┴└──┘ ┴┴└──┘┴
st ───────────────────────────────────┘└─
1586 end
st ──┘
1587
1588 end pi
1589
1590 section inclusion
1591 variable {α : Type*}
1592
1593 /-- `inclusion` is the "identity" function between two subsets `s` and `t`, where `s ⊆ t` -/
1594 def inclusion {s t : set α} (h : s ⊆ t) : s → t :=
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴
1595 λ x : s, (⟨x, h x.2⟩ : t)
id ┴ ┴ ┴ ┴┴ ┴
src ┴
typ ┴ ┴ ┴ ┴┴ ┴
1596
1597 @[simp] lemma inclusion_self {s : set α} (x : s) :
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
doc └──┘
1598 inclusion (set.subset.refl _) x = x := by cases x; refl
id └───────┘ └─────────────┘ ┴ ┴ ┴ ┴
src └───────┘ └─────────────┘ ┴ └────┘ └────
typ └───────┘ └─────────────┘ ┴ ┴ ┴ └────┘┴ └────
doc └───────┘ └────┘ └────
txt └────┘ └────
par └────┘ └────
pid ┴ └
st └──────────────
1599
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1600 @[simp] lemma inclusion_inclusion {s t u : set α} (hst : s ⊆ t) (htu : t ⊆ u)
id └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
1601 (x : s) : inclusion htu (inclusion hst x) = inclusion (set.subset.trans hst htu) x :=
id ┴ └───────┘ └─┘ └───────┘ └─┘ ┴ ┴ └───────┘ └──────────────┘ └─┘ └─┘ ┴
src └───────┘ └───────┘ ┴ └───────┘ └──────────────┘
typ ┴ └───────┘ └─┘ └───────┘ └─┘ ┴ ┴ └───────┘ └──────────────┘ └─┘ └─┘ ┴
doc └───────┘ └───────┘ └───────┘
1602 by cases x; refl
id ┴
src └────┘ └────
typ └────┘┴ └────
doc └────┘ └────
txt └────┘ └────
par └────┘ └────
pid ┴ └
st └──────────────
1603
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
1604 lemma inclusion_injective {s t : set α} (h : s ⊆ t) :
id └─┘ ┴ ┴ ┴ ┴
src └─┘ ┴
typ └─┘ ┴ ┴ ┴ ┴
1605 function.injective (inclusion h)
id └────────────────┘ └───────┘ ┴
src └────────────────┘ └───────┘
typ └────────────────┘ └───────┘ ┴
doc └───────┘
1606 | ⟨_, _⟩ ⟨_, _⟩ := subtype.ext.2 ∘ subtype.ext.1
id └─────────┘┴ ┴ └─────────┘┴
src └─────────┘┴ ┴ └─────────┘┴
typ └─────────┘┴ ┴ └─────────┘┴
1607
1608 end inclusion
1609
1610 end set